gorsa 支持公钥加密私钥解密;支持公钥解密私钥加密。

gorsa 支持公钥加密私钥解密;支持公钥解密私钥加密。

Go 安全相关

详细介绍

gorsa

gorsa 支持公钥加密私钥解密;支持公钥解密私钥加密。

gorsa 使用方法

使用方法:

go get github.com/bibinbin/gorsa

gorsa 公钥加密私钥解密

    // 设置publickey
    if err := RSA.SetPublicKey(Pubkey); err != nil {
        t.Error(err)
    }
    // 设置private key
    if err := RSA.SetPrivateKey(Pirvatekey); err != nil {
        t.Error(err)
    }
    // 公钥加密
    pubenctypt, err := RSA.PubKeyENCTYPT([]byte(`hello world`))
        if err != nil {
        t.Error(err)
    }
        // 私钥解密
    pridecrypt, err := RSA.PriKeyDECRYPT(pubenctypt)
    if err != nil {
        t.Error(err)
    }
    if string(pridecrypt) != `hello world` {
        t.Error(`不符合预期`)
    }

gorsa 公钥解密私钥加密

    if err := RSA.SetPublicKey(Pubkey); err != nil {
        t.Error(err)
    }
    if err := RSA.SetPrivateKey(Pirvatekey); err != nil {
        t.Error(err)
    }
    // 私钥加密
    prienctypt, err := RSA.PriKeyENCTYPT([]byte(`hello world`))
    if err != nil {
        t.Error(err)
    }
    // 公钥解密
    pubdecrypt, err := RSA.PubKeyDECRYPT(prienctypt)
    if err != nil {
        t.Error(err)
    }
    if string(pubdecrypt) != `hello world` {
        t.Error(`不符合预期`)
    }
推荐源码