by Robin at 20240110; fix
This commit is contained in:
parent
9ee9789d03
commit
a8280c6d27
|
@ -34,12 +34,14 @@ 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")
|
||||||
|
if name != "" {
|
||||||
field := pVal.Field(i)
|
field := pVal.Field(i)
|
||||||
if name != "_id" && !field.IsNil() {
|
if name != "_id" && !field.IsNil() {
|
||||||
value := field.Elem().Interface()
|
value := field.Elem().Interface()
|
||||||
set[name] = value
|
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))
|
||||||
|
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))
|
// phoneHash := mycrypto.CryptoServiceInstance().SHA256.Encrypt([]byte(mobilePhone))
|
||||||
base64EncryptedBytes := make([]byte, base64.StdEncoding.EncodedLen(len(rsaBytes)))
|
|
||||||
base64.StdEncoding.Encode(base64EncryptedBytes, rsaBytes)
|
|
||||||
|
|
||||||
base64EncryptedBytes2 := make([]byte, base64.StdEncoding.EncodedLen(len(rsaBytes2)))
|
|
||||||
base64.StdEncoding.Encode(base64EncryptedBytes2, rsaBytes2)
|
|
||||||
|
|
||||||
// fmt.Printf("Time:%v\n", time.Now().Unix())
|
// fmt.Printf("Time:%v\n", time.Now().Unix())
|
||||||
fmt.Printf("RSA:%v\n", string(base64EncryptedBytes))
|
// fmt.Printf("RSA:%v\n", string(base64EncryptedBytes))
|
||||||
fmt.Printf("RSA:%v\n", string(base64EncryptedBytes2))
|
|
||||||
// fmt.Printf("PhoneHash:%v\n", phoneHash)
|
// fmt.Printf("PhoneHash:%v\n", phoneHash)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue