diff --git a/.husky/pre-push b/.husky/pre-push index 041d054..35944e4 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,4 +1,3 @@ -yarn check:license yarn lint yarn test:prod yarn build diff --git a/example/aes-compressed-realm.js b/example/aes-compressed-realm.js index 999cb43..5a09827 100644 --- a/example/aes-compressed-realm.js +++ b/example/aes-compressed-realm.js @@ -1,10 +1,15 @@ -var data = {data: [{age: 1}, {age: '2'}]}; -var aesCRealm1 = new SecureLS({encodingType: 'aes', encryptionSecret: 'secret1', encryptionNamespace: 'realm1'}); +var data = { data: [{ age: 1 }, { age: '2' }] }; +var aesCRealm1 = new SecureLS({ + encodingType: 'aes', + encryptionSecret: 'secret1', + encryptionNamespace: 'realm1', + metaKey: '__meta__', +}); var key1 = 'aes__compressed_1'; var ae = aesCRealm1.AES.encrypt(JSON.stringify(data), ''); var bde = aesCRealm1.AES.decrypt(ae.toString(), ''); var de = bde.toString(aesCRealm1.enc._Utf8); -var aesCRealm2 = new SecureLS({encodingType: 'aes', encryptionSecret: 'secret2', encryptionNamespace: 'realm2'}); +var aesCRealm2 = new SecureLS({ encodingType: 'aes', encryptionSecret: 'secret2', encryptionNamespace: 'realm2' }); var key2 = 'aes__compressed_2'; var ae2 = aesCRealm2.AES.encrypt(JSON.stringify(data), ''); var bde2 = aesCRealm2.AES.decrypt(ae2.toString(), ''); diff --git a/example/aes-compressed.js b/example/aes-compressed.js index 7e09d96..03310c7 100644 --- a/example/aes-compressed.js +++ b/example/aes-compressed.js @@ -1,12 +1,12 @@ var key = 'aes__compressed'; -var data = {data: [{age: 1}, {age: '2'}]}; -var aes_c = new SecureLS({encodingType: 'aes', encryptionSecret: ''}); -ae = aes_c.AES.encrypt(JSON.stringify(data), '') -bde = aes_c.AES.decrypt(ae.toString(), '') -de = bde.toString(aes_c.enc._Utf8) +var data = { data: [{ age: 1 }, { age: '2' }] }; +var aes_c = new SecureLS({ encodingType: 'aes', encryptionSecret: '' }); +ae = aes_c.AES.encrypt(JSON.stringify(data), ''); +bde = aes_c.AES.decrypt(ae.toString(), ''); +de = bde.toString(aes_c.enc._Utf8); aes_c.set(key, data); console.log('AES Compressed'); console.log(localStorage.getItem(key)); console.log(aes_c.get(key)); -console.log('____________________________________') \ No newline at end of file +console.log('____________________________________'); diff --git a/example/aes-uncompressed.js b/example/aes-uncompressed.js index 4a90a71..7f3f1c9 100644 --- a/example/aes-uncompressed.js +++ b/example/aes-uncompressed.js @@ -1,6 +1,6 @@ var key = 'aes__uncompressed'; -var data = {data: [{age: 1}, {age: '2'}]}; -var aes_u = new SecureLS({encodingType: 'aes', isCompression: false}); +var data = { data: [{ age: 1 }, { age: '2' }] }; +var aes_u = new SecureLS({ encodingType: 'aes', isCompression: false }); ae = aes_u.AES.encrypt(JSON.stringify(data), 's3cr3t@123'); bde = aes_u.AES.decrypt(ae.toString(), 's3cr3t@123'); de = bde.toString(aes_u.enc._Utf8); @@ -9,4 +9,4 @@ aes_u.set(key, data); console.log('AES NOT Compressed'); console.log(localStorage.getItem(key)); console.log(aes_u.get(key)); -console.log('____________________________________') \ No newline at end of file +console.log('____________________________________'); diff --git a/example/base64-compressed.js b/example/base64-compressed.js index 32b1814..156e9ac 100644 --- a/example/base64-compressed.js +++ b/example/base64-compressed.js @@ -1,5 +1,5 @@ var key = 'base64__compressed'; -var data = {data: [{age: 1}, {age: '2'}]}; +var data = { data: [{ age: 1 }, { age: '2' }] }; var b_c = new SecureLS(); ae = b_c.AES.encrypt(JSON.stringify(data), 's3cr3t@123'); bde = b_c.AES.decrypt(ae.toString(), 's3cr3t@123'); @@ -9,4 +9,4 @@ b_c.set(key, data); console.log('Base64 Compressed'); console.log(localStorage.getItem(key)); console.log(b_c.get(key)); -console.log('____________________________________') \ No newline at end of file +console.log('____________________________________'); diff --git a/example/des-compressed.js b/example/des-compressed.js index c9acf4f..c7971fd 100644 --- a/example/des-compressed.js +++ b/example/des-compressed.js @@ -1,6 +1,6 @@ var key = 'des__compressed'; -var data = {data: [{age: 1}, {age: '2'}]}; -var des_c = new SecureLS({encodingType: 'des'}); +var data = { data: [{ age: 1 }, { age: '2' }] }; +var des_c = new SecureLS({ encodingType: 'des' }); ae = des_c.DES.encrypt(JSON.stringify(data), 's3cr3t@123'); bde = des_c.DES.decrypt(ae.toString(), 's3cr3t@123'); de = bde.toString(des_c.enc._Utf8); @@ -9,4 +9,4 @@ des_c.set(key, data); console.log('DES Compressed'); console.log(localStorage.getItem(key)); console.log(des_c.get(key)); -console.log('____________________________________') \ No newline at end of file +console.log('____________________________________'); diff --git a/example/des-uncompressed.js b/example/des-uncompressed.js index 38e0f1d..130fcef 100644 --- a/example/des-uncompressed.js +++ b/example/des-uncompressed.js @@ -1,6 +1,6 @@ var key = 'des__uncompressed'; -var data = {data: [{age: 1}, {age: '2'}]}; -var des_u = new SecureLS({encodingType: 'des', isCompression: false}); +var data = { data: [{ age: 1 }, { age: '2' }] }; +var des_u = new SecureLS({ encodingType: 'des', isCompression: false }); ae = des_u.DES.encrypt(JSON.stringify(data), 's3cr3t@123'); bde = des_u.DES.decrypt(ae.toString(), 's3cr3t@123'); de = bde.toString(des_u.enc._Utf8); @@ -9,4 +9,4 @@ des_u.set(key, data); console.log('DES not Compressed'); console.log(localStorage.getItem(key)); console.log(des_u.get(key)); -console.log('____________________________________') \ No newline at end of file +console.log('____________________________________'); diff --git a/example/index.html b/example/index.html index 2007d9d..a49d29f 100644 --- a/example/index.html +++ b/example/index.html @@ -1,36 +1,40 @@ - + -
-{"data":[{"age":1},{"age":"2"}]}+ Output: +
{"data":[{"age":1},{"age":"2"}]}+ - - - Open console to check localStorage data. -
{"data":[{"age":1},{"age":"2"}]}- Output:
{"data":[{"age":1},{"age":"2"}]}- - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + +