by Robin at 20240110; fix
This commit is contained in:
parent
9ee9789d03
commit
a8280c6d27
|
@ -34,10 +34,12 @@ func EntityToM(p any) qmgo.M {
|
||||||
pVal := reflect.ValueOf(p).Elem()
|
pVal := reflect.ValueOf(p).Elem()
|
||||||
for i := 0; i < pType.NumField(); i++ {
|
for i := 0; i < pType.NumField(); i++ {
|
||||||
name := pType.Field(i).Tag.Get("bson")
|
name := pType.Field(i).Tag.Get("bson")
|
||||||
field := pVal.Field(i)
|
if name != "" {
|
||||||
if name != "_id" && !field.IsNil() {
|
field := pVal.Field(i)
|
||||||
value := field.Elem().Interface()
|
if name != "_id" && !field.IsNil() {
|
||||||
set[name] = value
|
value := field.Elem().Interface()
|
||||||
|
set[name] = value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return set
|
return set
|
||||||
|
|
|
@ -25,20 +25,20 @@ func Test(t *testing.T) {
|
||||||
logger.Error("cryptoService init, err: %v", err)
|
logger.Error("cryptoService init, err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
name := "迟泓清"
|
mobilePhone := "Loum3xCiIgJ/tnp+AdxbIw=="
|
||||||
IDNo := "231544199805061257"
|
base64DecryptedBytes, _ := base64.StdEncoding.DecodeString(mobilePhone)
|
||||||
rsaBytes, _ := mycrypto.CryptoServiceInstance().RSA.Encrypt([]byte(name))
|
phone, _ := mycrypto.CryptoServiceInstance().AES.Decrypt(base64DecryptedBytes)
|
||||||
rsaBytes2, _ := mycrypto.CryptoServiceInstance().RSA.Encrypt([]byte(IDNo))
|
fmt.Println(string(phone))
|
||||||
//phoneHash := mycrypto.CryptoServiceInstance().SHA256.Encrypt([]byte(mobilePhone))
|
hash := mycrypto.CryptoServiceInstance().SHA256.Encrypt(phone)
|
||||||
base64EncryptedBytes := make([]byte, base64.StdEncoding.EncodedLen(len(rsaBytes)))
|
fmt.Println(string(hash))
|
||||||
base64.StdEncoding.Encode(base64EncryptedBytes, rsaBytes)
|
// mobilePhone := "17738729985"
|
||||||
|
// rsaBytes, _ := mycrypto.CryptoServiceInstance().RSA.Encrypt([]byte(mobilePhone))
|
||||||
|
// base64EncryptedBytes := make([]byte, base64.StdEncoding.EncodedLen(len(rsaBytes)))
|
||||||
|
// base64.StdEncoding.Encode(base64EncryptedBytes, rsaBytes)
|
||||||
|
// phoneHash := mycrypto.CryptoServiceInstance().SHA256.Encrypt([]byte(mobilePhone))
|
||||||
|
|
||||||
base64EncryptedBytes2 := make([]byte, base64.StdEncoding.EncodedLen(len(rsaBytes2)))
|
// fmt.Printf("Time:%v\n", time.Now().Unix())
|
||||||
base64.StdEncoding.Encode(base64EncryptedBytes2, rsaBytes2)
|
// fmt.Printf("RSA:%v\n", string(base64EncryptedBytes))
|
||||||
|
// fmt.Printf("PhoneHash:%v\n", phoneHash)
|
||||||
//fmt.Printf("Time:%v\n", time.Now().Unix())
|
|
||||||
fmt.Printf("RSA:%v\n", string(base64EncryptedBytes))
|
|
||||||
fmt.Printf("RSA:%v\n", string(base64EncryptedBytes2))
|
|
||||||
//fmt.Printf("PhoneHash:%v\n", phoneHash)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue