From 5941d86e5d393471ac23e7d57f084052bb07c808 Mon Sep 17 00:00:00 2001 From: Hank Shen Date: Thu, 1 Jul 2021 23:17:42 +0800 Subject: [PATCH] update --- rsa_private_key.go | 4 +++- rsa_public_key.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rsa_private_key.go b/rsa_private_key.go index c1ae853..7a844ac 100644 --- a/rsa_private_key.go +++ b/rsa_private_key.go @@ -14,7 +14,9 @@ import ( // 设置私钥 func NewRSAPrivateKey(privateKey []byte) (r *RSAPrivateKey, err error) { r = &RSAPrivateKey{} - err = r.SetPrivateKeyBytes(privateKey) + if privateKey != nil { + err = r.SetPrivateKeyBytes(privateKey) + } return } diff --git a/rsa_public_key.go b/rsa_public_key.go index 9a468fa..980b990 100644 --- a/rsa_public_key.go +++ b/rsa_public_key.go @@ -14,7 +14,9 @@ import ( // 设置公钥 func NewRSAPublicKey(publicKey []byte) (r *RSAPublicKey, err error) { r = &RSAPublicKey{} - err = r.SetPublicKeyBytes(publicKey) + if publicKey != nil { + err = r.SetPublicKeyBytes(publicKey) + } return }