Getting random AES encryped value


I am using CryptoJS to encrypt the password. Below is the code that i’m using to generate the encrypted password,but it is generating random value on every attempt .

let encrypted = CryptoJS.AES.encrypt(“pass”, “secret Key”);

Anyone have idea about this and Implememnted this in ionic 3

    encrypt(data, key) {
        return CryptoJS.AES.encrypt(JSON.stringify(data), key).toString();

    decrypt(data, key) {
        let bytes = CryptoJS.AES.decrypt(data, key);
        return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
1 Like

Dear @kamakshi,

Did you get solution for it ? I am looking a same implementation corresponding to mcrypt in PHP of backend . Please advise


You’re awesome!!! It worked like a charm!

1 Like