你好,我想知道如何通过 GO 中的字符串加载 RSA 公钥?我读过一些文档,但我不知道如何加载它?我不想通过 PEM 加载,我想通过
-----BEGIN PUBLIC KEY-----
KEY
-----END PUBLIC KEY-----
Run Code Online (Sandbox Code Playgroud)
我尝试使用 rsa.EncryptOAEP 但我需要公钥参数,但我不知道如何做到这一点。
func main() {
pubPem, err := pem.Decode([]byte("KEY"))
if err != nil {
fmt.Println(string(err))
return
}
if pubPem.Type != "RSA PUBLIC KEY" {
fmt.Println("not rsa?")
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试过这个,但它不起作用,因为它的 pem.Decode (我认为)