JavaScript使⽤RSA进⾏超长⽂本加解密
JavaScript-RSA加解密
RSA加密库
RSA前端加解密。是通过⽤jncrypt.min.js来实现的,此js⽂件实现了对超长⽂本字段加密功能。写这个⽂件的⼤师很⽜!膜拜⼀下��
RSA加密⽅法:
var encrypt = new JSEncrypt();
encrypt.tPublicKey("-----BEGIN PUBLIC KEY-----\
niche
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLFb8qp1vRFvi/qfgi1Wg7Mi8l\
exotic什么意思LcpfAc+tgpyD7aFW9QquQVMm/jG1IJZVQ6LsdkI7TiDutMCzOMCBXbdSC9BCIAGA\
L2Sz3cYVlGb1kYSM0ZMcUMIK5eF4Bptke070XHvbi8wArtysJ0l71RHDd786tNbG\
W0hDSw3zAqTErbxFaQIDAQAB\
-----END PUBLIC KEY-----\
"); //设置公钥加密证书
var data = "123+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA var commonEncodeData = ptLong(data); //不含中⽂的
stateoftheartvar cnEscapeData = window.deURIComponent(data2)); //包含中⽂
6级评分标准var encryptData = ptLong(cnEscapeData); //获取加密后数据。
RSA解密⽅法:
encrypt.tPrivateKey("-----BEGIN PRIVATE KEY-----\
MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAMsVvyqnW9EW+L+p\
+CLVaDsyLyUtyl8Bz62CnIPtoVb1Cq5BUyb+MbUgllVDoux2QjtOIO60wLM4wIFd\
t1IL0EIgAYAvZLPdxhWUZvWRhIzRkxxQwgrl4XgGm2R7TvRce9uLzACu3KwnSXvV\
EcN3vzq01sZbSENLDfMCpMStvEVpAgMBAAECgYAPmwAxmuKnUoiS0dDLfHKh+d09\
kiM24cC/qIW2bZA0Smgjs8lb+bSAIpzquGPQn9W/EOXe8ezM2NOSHU109ItwJkHA\
iHuKDDrhx82Z7n/pyKGjnu6ysxvi+S+RTD5QyoCpo0/a6QTUlI2PbuWeYbjf/o4t\
rwWON7z3tv11BOnoAQJBAPJrZB+Ay4eeOGCuveyBusKPin2CxXy+HiB33SbdrJrE\
北京西门子plc培训
ymBB7PnhfDd41EOIpr7d1Obm86jMWR6uEvDZOL0KTsECQQDWdj9UNR0DJbp/mGik\
tsIrtrIgZZ5hR6R4AT3vZ3ez0HoXvWh0IVVHwC9fqjDizjJjr1p28f1sq4tH0qm1\
yEipAkA0DUsaWJVbMWX5nIu7VL+9NwUNnh65gjkFz7b0uXRuZwLtWDqCDSCW6KLr\
PVRQd2FXkw+OlxIrvETk4j+El8oBAkA/tBItpjU++RcDzbbProXQzEzu+KBqDwjY\
qK3IDjjtTbDmmlmLnVcioACybvBkfpFTMQQzLsBzZiVSKU5F8/85AkA0L4+xRInJ\更新英文
VjFez8IHDRDgyM/D3uCJ/UEV8qYuP3noFer/uFNsMINXS1jwayhaYAG4+7ynUMXt\
tafe
dpba6zGedNEM\tongue
-
----END PRIVATE KEY-----");
var commonDecryptData = encrypt.decryptLong2(commonEncodeData); //不含中⽂
prevent的用法var cndecryptData = encrypt.decryptLong2(encryptData); //含中⽂
darling的意思
var cndecodeData = window.decodeURIComponent(window.atob(cndecryptData));
是不是很简单呢?都是⼤神的杰作。
demo传送门: