Skip to content

DecryptOAEP #254

@yongliu1992

Description

@yongliu1992

此函数为什么 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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions