小编the*_*dev的帖子

GO RSA 加载公钥

你好,我想知道如何通过 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 (我认为)

encryption rsa go

1
推荐指数
1
解决办法
3815
查看次数

标签 统计

encryption ×1

go ×1

rsa ×1