Open jerryshao2012 opened 8 years ago
+1
+1
@alpertayfun @jerryshao2012
Hi guys! I make it in browserify.
here is what have I done.
browserify ./dist/CryptLib.js --standalone CryptLib -o CryptLib.browser.js
Then you can load the CryptLib.browser.js in your html.
<script src="./dist/CryptLib.browser.js" charset="utf-8"></script>
<script>
var _crypt = new CryptLib();
plainText = 'This is the text to be encrypted';
// 16 bytes = 128 bit
iv = _crypt.generateRandomIV(16);
//32 bytes = 256 bits
key = _crypt.getHashSha256('my secret key', 32),
cypherText = _crypt.encrypt(plainText, key, iv);
console.log('iv = %s', iv);
console.log('key = %s', key);
console.log('Cypher text = %s', cypherText);
console.log('Plain text = %s', _crypt.decrypt(cypherText, key, iv));
</script>
Any plan to add JavaScript version?