|
300精币
附golang源码
func RsaDecrypt(priv *rsa.PrivateKey, encryptedData []byte, chunkSize int) ([]byte, error) { // RSA分段解密
var decryptedData []byte
for len(encryptedData) > 0 {
size := chunkSize
if len(encryptedData) < chunkSize {
size = len(encryptedData)
}
decryptedChunk, err := rsa.DecryptPKCS1v15(rand.Reader, priv, encryptedData[:size])
if err != nil {
return nil, fmt.Errorf("解密失败: " + err.Error())
}
decryptedData = append(decryptedData, decryptedChunk...)
encryptedData = encryptedData[size:]
}
return decryptedData, nil
}
func RsaDecrypt(priv *rsa.PrivateKey, encryptedData []byte, chunkSize int) ([]byte, error) { // RSA分段解密
var decryptedData []byte
for len(encryptedData) > 0 {
size := chunkSize
if len(encryptedData) < chunkSize {
size = len(encryptedData)
}
decryptedChunk, err := rsa.DecryptPKCS1v15(rand.Reader, priv, encryptedData[:size])
if err != nil {
return nil, fmt.Errorf("解密失败: " + err.Error())
}
decryptedData = append(decryptedData, decryptedChunk...)
encryptedData = encryptedData[size:]
}
return decryptedData, nil
}
我希望用易语言来完成这个加解密的操作 不要用js调用 我试过了 卡的无法直视 也不要某某模块 我要源码 各位大佬帮帮忙
现在附上用于测试的RSA秘钥 分别是
公钥 [color=rgba(0, 0, 0, 0.85)]PKIX 格式
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3aB1X7apDvwoK0cLw7tbj1svF
4CQmsobk5UL3Ee7QKc2xJgwUIJBx3qXMRrgAol0SPOYL9LHRCU7RRkj4rJYDpPec
snxcl//YWaSlly/JoxDMIroI9P9AQbbxHi/p4xZmPf1hvqYELz+cdl+diOFWXTct
Ru7Ewhrz1zOpDZDh3wIDAQAB
-----END PUBLIC KEY-----
私钥 PKCS8 1024位 -----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALdoHVftqkO/CgrR
wvDu1uPWy8XgJCayhuTlQvcR7tApzbEmDBQgkHHepcxGuACiXRI85gv0sdEJTtFG
SPislgOk95yyfFyX/9hZpKWXL8mjEMwiugj0/0BBtvEeL+njFmY9/WG+pgQvP5x2
X52I4VZdNy1G7sTCGvPXM6kNkOHfAgMBAAECgYEArBs0Zf2taBNOXibG8wZ9eqJm
6BHUesfO097bvzQB0S9ZSSI19XE1etV+6jl2k4nJIsMo8RE3B7zfTHzTHx/9SGcv
vgVkx/XYsgf3OScYLbnOzDcyFiNdU5o3/EPl6HAjmyCxLOV4xUGttFd0Zow81OW+
vp9as3Ug7pVApFW9GgkCQQDxSXW/AkLbNv1GqmZkDU+4JrrXYMyPYxF9cuwrGU9L
c6Df/PgBsUR5n4LJRJnlRb+jl//PtNmdk2+g65eWliudAkEAwpchuOJQzpPIQH/Z
9lmZW7ukJi/qdyMckLEjNV+5UzsBypARh0iy1AvdB5P7O2TNpivOxMznNa2NTXMz
CPzAqwJAP8Y00vmcBijwpL7hNUy3Z2sFM2woZTXAJ7I6beHQrZawTMOmIXxjJupc
PSpeqtTWpDzGpnWclyOi+5uJg4nJmQJBALZBpbUsTDFgW3SGC1lgzHIOCw41XO8f
dNbVArwwHz2ki+X1EGXcoppXTjuVz/7uSGu2pmDP5lLxbeK33noxeicCQGDFFo0j
F/phjyvV39Zy9n7lpZFpXf5p+2UhlUJMRrR2oKP5ARFgF8ChSwJk/k9ZKKbD/xkr
Cq0CUZ/fct6np8Q=
-----END PRIVATE KEY-----
补充内容 (2024-9-22 19:32):
func RsaEncrypt(pub *rsa.PublicKey, data []byte, chunkSize int) ([]byte, error) { // RSA分段加密
var encryptedData []byte
for len(data) > 0 {
size := chunkSize
if len(data) < chunkSize {
... |
|