Mike96Angelo / Secure-Storage

A simple wrapper for localStorage/sessionStorage that allows one to encrypt/decrypt the data being stored.
MIT License
27 stars 8 forks source link

hash key -_.hash is not a function #3

Closed leomartinsm closed 3 years ago

leomartinsm commented 4 years ago

i have an error _.hash, but i don't need to hash the key, my problem is relative only for the value

Mike96Angelo commented 3 years ago

As shown on the README.md you must supply your own hash, encrypt, and decrypt functions.

if you don't wish to hash the key, use an identity function for the hash:

var secureStorage = new SecureStorage(localStorage, {
    hash: function hash(key) {
        return key;
    },
    encrypt: function encrypt(data) {
        data = CryptoJS.AES.encrypt(data, SECRET_KEY);

        data = data.toString();

        return data;
    },
    decrypt: function decrypt(data) {
        data = CryptoJS.AES.decrypt(data, SECRET_KEY);

        data = data.toString(CryptoJS.enc.Utf8);

        return data;
    }
});