Skip to content

Instantly share code, notes, and snippets.

@nwoow
Created November 12, 2020 06:23
Show Gist options
  • Select an option

  • Save nwoow/b417de31c725fa7ffcb3d63606ec7a3b to your computer and use it in GitHub Desktop.

Select an option

Save nwoow/b417de31c725fa7ffcb3d63606ec7a3b to your computer and use it in GitHub Desktop.
var CryptLib = require('cryptlib'),
crypt = CryptLib
plainText = 'This is the text to be encrypted'
// iv = _crypt.generateRandomIV(16), //16 bytes = 128 bit
key = crypt.getHashSha256('4E645267556B58703273357538782F413F4428472B4B6250655368566D597133', 32), //32 bytes = 256 bits
iv = "Vmr-uU5mA2_Zr_13"
cypherText = "bvtkHfZiTsY0CX6QmHhCboBwXeY9RZVPpdhhdIy6aSwCTVI7YiEGha1aXTIKY4BocGdNIbWkreQHZcTk4WE6F2tQLoVyWERYCGZotbDzxxs="
// cypherText = _crypt.encrypt(plainText, key, iv),
originalText = crypt.decrypt(cypherText, key, iv);
console.log(originalText)
//output
{
"AppId": "hhhhhh85812",
"emailId": "[email protected]"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment