问题描述
我需要Encrypt
中的angularjs
和Decrypt
中的nodejs
的一些数据。我已经看到了这个stackoverflow
答案:
Angular CryptoJs Encryption Not Decryption in Node JS CryptoJS
并尝试通过以下方式在我的CryptoJS
应用中使用angularjs
:
HTML
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.js"></script>
JS
app.controller('test',function ($scope) {
var param = 'abc'
var encry = CryptoJS.AES.encrypt(param,'key');
console.log(encry);
});
但是出现此错误:
CryptoJS is not defined
我是angularjs
的新手,所以对如何使用不同的库没有太多的了解。
encryption
中的angularjs
和decryption
中的nodejs
的示例将非常有帮助。
解决方法
您可以尝试删除HTML中已经具有的与crypto-js关联的两个脚本,并将其替换为:
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js"></script>
我希望这行得通。