0
在客戶端的瀏覽器中,我使用jsencrypt.js和一個公鑰對rand_key變量進行加密。 加密密鑰通過郵件正文發送到服務器。 (這是內我給出的IT結構達到的唯一方式。) 在我的瀏覽器,我有:瀏覽器加密服務器解密
<!DOCTYPE html>
<html lang="en">
<head>
<script type="application/javascript" src="jsencrypt.js"></script>
</head>
<body>
<script>
var pubkey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALDjeFwFNhMCjMwcRVVKG1VvfsntEVPR3lNTujJnNk1+iSqZ4Tl5Lwq9GbwO+qlYVwXHNmeqG7rkEhL9uyDIZVECAwEAAQ=="
var rand_key = 'vpeq91mckhntgldi';
// Encrypt rand_key
var encrypt = new JSEncrypt();
//console.log('encrypt obj', encrypt);
encrypt.setPublicKey(pubkey);
var encrypted_rand_key = encrypt.encrypt(rand_key, 'base64');
console.log('encrypted_rand_key', encrypted_rand_key);
</script>
</body>
</html>
在我的PC上運行的節點(在我收到的電子郵件):
var CryptoJS = require("crypto-js");
// encrypted string copied from browser console
var encrypted = 'IuRaUfDHDIJsO0JZbEj7RS/1Sw0iSZPB267MN9lmF5Fn/kuMMRyKlAjplwvUJ9qvirajOcAQNnRZs9A+gVcWLQ=='
IuRaUfDHDIJsO0JZbEj7RS/1Sw0iSZPB267MN9lmF5Fn/kuMMRyKlAjplwvUJ9qvirajOcAQNnRZs9A+gVcWLQ==
var key_pri = new NodeRSA('-----BEGIN RSA PRIVATE KEY-----MIIBPAIBAAJBALDjeFwFNhMCjMwcRVVKG1VvfsntEVPR3lNTujJnNk1+iSqZ4Tl5Lwq9GbwO+qlYVwXHNmeqG7rkEhL9uyDIZVECAwEAAQJBAIS8vYX4FyLex/8mu9SLvsU23KL0dgs7MqW+77uA/hvZt5eb/C0EfUekap3LBuAF3XqVkOwIjsDyj74adrB6J1ECIQDfxT74mqu+xZjdlrfNZcchu/MrrW631aMF4rsRZccTbQIhAMpdneTSAATCwE8vt4bS6BBnv8Y8ZceNO6wGOvcW30b1AiAY2MEGP75kP3Ka4Dpmfy+eSk1VAzvxA7LHW4akBuYU/QIhAMk7gtGSCjaxuy6DUssdW2tE4C0uzj87sIUFxQkEk48pAiEAkHxKin7tcB4pVU2yurSbGkB+TbaCOfkIzR4griXq00k=-----END RSA PRIVATE KEY-----');
var decrypted = key_pri.decrypt(encrypted, 'utf8');
console.log('decrypted: ', decrypted);
不幸我收到一條錯誤消息:
Error: Error during decryption (probably incorrect key). Original error: Error: error:040A1079:rsa routines:RSA_padding_check_PKCS1_OAEP_mgf1:oaep decoding error
如何修復服務器(pc)端的描述? 謝謝!
太棒了!謝謝 ! – ArtDijk