0

I need to Encrypt some data in angularjs and Decrypt in nodejs. I've seen this stackoverflow answer:

Angular CryptoJs Encryption Not Decryption in Node JS CryptoJS

and tried to use CryptoJS in my angularjs app this way:

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);
});

But getting this error:

CryptoJS is not defined

I'm new in angularjs so don't have much idea about how to use different libraries. An example of encryption in angularjs and decryption in nodejs would be very helpful.

1 Answer 1

0

You could try to remove the two scripts associated with crypto-js that you already have in the HTML and replace them with:

<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js"></script>

I hope this works.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.