UNPKG

whstorage

Version:

whSotorage is a way to encrypt localSotage

37 lines (34 loc) 835 B
/* * Get KEY and PREFIX */ fetch('/api') .then((response) => response.json()) .then((data) => { /* * Configure WHS, send parames */ whStorage.init({ key: data.whKey, prefix: data.prefix }); /* * Store Data to localStorage throw whs */ whStorage.set('user', {name: "david",password: "lolita123"}) whStorage.set('setting', {video: true,audio: false}) }) /* * wait one second, because we send unsynchronized requests using fetch * and get data form storage. */ setTimeout(() => { let user = whStorage.get('user') let setting = whStorage.get('setting') console.log(user) console.log(setting) }, 1000) /* * try to decrypt without key */ // let value = sjcl.decrypt("bla123", localStorage.getItem('wh_user')) // console.log(value)