fix rsa util
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
@@ -22,7 +23,7 @@ func EncryptWithPublicKey(data string, pemBytes []byte) (string, error) {
|
||||
if !ok {
|
||||
return "", errors.New("not RSA public key")
|
||||
}
|
||||
ciphertext, err := rsa.EncryptPKCS1v15(nil, pubKey, []byte(data))
|
||||
ciphertext, err := rsa.EncryptPKCS1v15(rand.Reader, pubKey, []byte(data))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user