From 2c43e758f5e136ac1f152628e83d1e4ca3e1731e Mon Sep 17 00:00:00 2001 From: Aditya Siregar Date: Thu, 7 May 2026 09:48:37 +0700 Subject: [PATCH] fix rsa util --- internal/util/rsa_util.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/util/rsa_util.go b/internal/util/rsa_util.go index 9d94590..c0517df 100644 --- a/internal/util/rsa_util.go +++ b/internal/util/rsa_util.go @@ -1,6 +1,7 @@ package util import ( + "crypto/rand" "crypto/rsa" "crypto/x509" "encoding/base64" @@ -22,9 +23,9 @@ 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)) - if err != nil { - return "", err - } - return base64.StdEncoding.EncodeToString(ciphertext), nil + ciphertext, err := rsa.EncryptPKCS1v15(rand.Reader, pubKey, []byte(data)) + if err != nil { + return "", err + } + return base64.StdEncoding.EncodeToString(ciphertext), nil }