mervick / aes-everywhere

Aes Everywhere - Cross Language AES 256 Encryption Library (Bash, Powershell, C#, Dart, GoLang, Java, JavaScript, Lua, PHP, Python, Ruby, Swift)
Other
474 stars 169 forks source link

how to run javascript version in the browser? #35

Closed flatsiedatsie closed 3 years ago

flatsiedatsie commented 3 years ago

The documentation of the javascript version says "Works well both on the browsers". But the script actually doesn't run in the browser? It uses require, which assumed NodeJS?

mervick commented 3 years ago

These files javascript/dist/aes256.js and javascript/dist/aes256.min.js does not require node.js

flatsiedatsie commented 3 years ago

Thanks for the quick response. I managed to get it to work by adding crypto-js manually, and removing the require code.

For anyone finding this, remove these two lines:

var CryptoJS = require('node-cryptojs-aes').CryptoJS; and module.exports = AES256;

and find the latest copy of crypto-js.min.js and load that in your html before the aes256 part. E.g.

    <script src="js/crypto-js.min.js"></script>
    <script src="js/aes256.js"></script>