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()
|
||||
for i := 0; i < pType.NumField(); i++ {
|
||||
name := pType.Field(i).Tag.Get("bson")
|
||||
field := pVal.Field(i)
|
||||
if name != "_id" && !field.IsNil() {
|
||||
value := field.Elem().Interface()
|
||||
set[name] = value
|
||||
if name != "" {
|
||||
field := pVal.Field(i)
|
||||
if name != "_id" && !field.IsNil() {
|
||||
value := field.Elem().Interface()
|
||||
set[name] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
return set
|
||||
|
|
|
@ -25,20 +25,20 @@ func Test(t *testing.T) {
|
|||
logger.Error("cryptoService init, err: %v", err)
|
||||
}
|
||||
|
||||
name := "迟泓清"
|
||||
IDNo := "231544199805061257"
|
||||
rsaBytes, _ := mycrypto.CryptoServiceInstance().RSA.Encrypt([]byte(name))
|
||||
rsaBytes2, _ := mycrypto.CryptoServiceInstance().RSA.Encrypt([]byte(IDNo))
|
||||
//phoneHash := mycrypto.CryptoServiceInstance().SHA256.Encrypt([]byte(mobilePhone))
|
||||
base64EncryptedBytes := make([]byte, base64.StdEncoding.EncodedLen(len(rsaBytes)))
|
||||
base64.StdEncoding.Encode(base64EncryptedBytes, rsaBytes)
|
||||
mobilePhone := "Loum3xCiIgJ/tnp+AdxbIw=="
|
||||
base64DecryptedBytes, _ := base64.StdEncoding.DecodeString(mobilePhone)
|
||||
phone, _ := mycrypto.CryptoServiceInstance().AES.Decrypt(base64DecryptedBytes)
|
||||
fmt.Println(string(phone))
|
||||
hash := mycrypto.CryptoServiceInstance().SHA256.Encrypt(phone)
|
||||
fmt.Println(string(hash))
|
||||
// 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)))
|
||||
base64.StdEncoding.Encode(base64EncryptedBytes2, rsaBytes2)
|
||||
|
||||
//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)
|
||||
// fmt.Printf("Time:%v\n", time.Now().Unix())
|
||||
// fmt.Printf("RSA:%v\n", string(base64EncryptedBytes))
|
||||
// fmt.Printf("PhoneHash:%v\n", phoneHash)
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue