-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Description
此函数为什么 rsa.DecryptOAEP 最后一个参数直接写为了nil,而不是可以从参数传下来?
func DecryptOAEP(ciphertext string, privateKey *rsa.PrivateKey) (message string, err error) {
if privateKey == nil {
return "", fmt.Errorf("you should input *rsa.PrivateKey")
}
decodedCiphertext, err := base64.StdEncoding.DecodeString(ciphertext)
if err != nil {
return "", fmt.Errorf("base64 decode failed, error=%s", err.Error())
}
messageBytes, err := rsa.DecryptOAEP(sha1.New(), rand.Reader, privateKey, decodedCiphertext, nil)
if err != nil {
return "", fmt.Errorf("decrypt ciphertext with private key err:%s", err)
}
return string(messageBytes), nil
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels