请在此处找到解决方案柱塞:
JSEncrypt与角度
https://plnkr.co/edit/sEPK1DcynMphJnGziUVX
我已经使用了JSEncrypt v2.3.0 Lib。
实作
在Angular Project的Asset文件夹中添加JSEncrypt Lib javascript文件。在中添加脚本
index.html
<script src="jsencrypt.js"></script>
因此,它将在所有组件上可用。
在要使用它的组件文件中声明JSEncrypt。
declare var JSEncrypt: any;
内部类声明变量
decrypt = new JSEncrypt();const privatekey = Private Key goes here;const publickey = Public key goes here;const decryptDataRow = Decrypted data string;this.decrypt.setPrivateKey(privatekey);this.decryptdata = this.decrypt.decrypt(decryptDataRow);
decryptdata包含结果字符串



