【问题标题】:How to Encrypt in Angularjs and Decrypt in Nodejs using CryptoJS如何使用 CryptoJS 在 Angularjs 中加密和在 Nodejs 中解密
【发布时间】:2020-08-18 19:14:16
【问题描述】:

我需要EncryptangularjsDecrypt 中的一些数据nodejs。我看过这个stackoverflow 答案:

Angular CryptoJs Encryption Not Decryption in Node JS CryptoJS

并尝试以这种方式在我的angularjs 应用程序中使用CryptoJS

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 的新手,所以对如何使用不同的库不太了解。 angularjs 中的 encryptionnodejs 中的 decryption 的示例将非常有帮助。

【问题讨论】:

    标签: node.js angularjs encryption cryptojs


    【解决方案1】:

    您可以尝试删除 HTML 中已有的与 crypto-js 关联的两个脚本,并将它们替换为:

    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js"&gt;&lt;/script&gt;

    我希望这行得通。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多