All is in the title. I want to use the CrytoJS lib in an AngularJS application and I can't get rid of this.
I install crytoJS with bower:
bower install cryptojslib
Then I load the lib I need :
<script type="text/javascript" src="/public/system/lib/cryptojslib/rollups/md5.js"></script>
<script type="text/javascript" src="/public/system/lib/cryptojslib/components/enc-base64-min.js"></script>
And I try to use the CryptoJS like that :
var pwd = CryptoJS.MD5(params.email+'|'+params.password).toString(CryptoJS.enc.Base64);
When I run this code, I've got the following error :
'CryptoJS is not defined'
I've read that it should be possible to wrap the CryptoJS into a module but I don't know how to do.
Any help would be greatly appreciated.
JM.
Shouldn't be any problems with AngularJS and CryptoJS. I setup a quick Plunker that has a hash created in a controller. No errors...
http://plnkr.co/edit/kzrr3EdHNXELVof6DVSp?p=preview
In the controller:
$scope.hash = CryptoJS.MD5("Message");
In the HTML:
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>
Is this different than what you are trying?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With