1 Star 1 Fork 0

cuihovah/kratos

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rsa.go 474 Bytes
一键复制 编辑 原始数据 按行查看 历史
cuiyunfeng 提交于 2025-10-20 10:02 +08:00 . 添加了登录工具
package rsa
import (
rrd "crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
)
func RSADecryptFactory(key string) func([]byte) []byte {
return func(cipherTxt []byte) []byte {
privateKey := []byte(key)
//通过私钥解密
block, _ := pem.Decode(privateKey)
//解析私钥
pri, err := x509.ParsePKCS1PrivateKey(block.Bytes)
_ = err
//解密
bits, err := rsa.DecryptPKCS1v15(rrd.Reader, pri, cipherTxt)
_ = err
//返回明文
return bits
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/cuihovah/kratos.git
git@gitee.com:cuihovah/kratos.git
cuihovah
kratos
kratos
36e0f0475783

搜索帮助