CryptoJS.AES.decrypt depending on what we want to do and pass in the message to be encrypted/decrypted along with a secret key used in the algorithm.
var encrypted = CryptoJS.AES.encrypt("This is my secret message", "EncryptionKey"); var decrypted = CryptoJS.AES.decrypt(encrypted, "EncryptionKey");
decrypt(). They use the
AES-256-CBC algorithm. We can encrypt/decrypt a string simply by calling
ncrypt.decrypt(). It also takes the message and secret key as the arguments. But it has an added advantage that we do not have to provide that secret key at the time of decryption.
import ncrypt from 'ncrypt-js'; const encrypted = ncrypt.encrypt('This is my secret message', 'Secret key'); console.log(encrypted); const decrypted = ncrypt.decrypt(encrypted); console.log(decrypted);