Last active
July 21, 2020 11:03
-
-
Save coturiv/40467ee5753c85a72d0980e47ac7859f to your computer and use it in GitHub Desktop.
AES Encryption
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const iv = CryptoJS.enc.Base64.parse("101112131415161718191a1b1c1d1e1f"); | |
| const encrypt = (message = '', key = '') => { | |
| const encrypted = CryptoJS.AES.encrypt(message, key, {iv}).toString(); | |
| return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(encrypted)); | |
| } | |
| const decrypt = (message = '', key = '') => { | |
| const decrypted = CryptoJS.enc.Base64.parse(message).toString(CryptoJS.enc.Utf8); | |
| return CryptoJS.AES.decrypt(decrypted, key, {iv}).toString(CryptoJS.enc.Utf8) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment