首先,帽尖到@Nathan Bubna他store2.js API。
现在,对于OP的问题:过滤本地存储内容,我可以建议使用localDataStorage,一个方便的实用程序,可让您透明地设置/获取以下任何“类型”:Array,Boolean,Date,Float,Integer,Null,Object或String。它还提供了简单的数据加扰,智能字符串压缩,按键查询以及按值查询,并且有助于在同一个域中实施共享存储分段。
[免责声明]我的实用程序的作者[/免责声明】
例子:
localDataStorage.set('key1', 'Belgian');
localDataStorage.set('key2', 1200.0047);
localDataStorage.set('key3', true);
localDataStorage.set('key4', { 'RSK' : [1,'3',5,'7',9] });
localDataStorage.set('key5', null);
localDataStorage.get('key1'); --> 'Belgian'
localDataStorage.get('key2'); --> 1200.0047
localDataStorage.get('key3'); --> true
localDataStorage.get('key4'); --> Object {RSK: Array(5)}
localDataStorage.get('key5'); --> null
正如你所看到的,原始价值得到尊重。现在,在你的情况,我们不妨去卖场一“市”键混淆形式:
>localDataStorage.safeset('City', 'Portland', 'our-secret-key');
这混淆存储在本地存储中的数据。它没有被加密,但它肯定不是明文。在我的机器,它看起来像这样存储:
ڕ³¼П٠ࢭ\B۳ث
现在,当我们检索...
>localDataStorage.safeget('City', 'our-secret-key'); -->
...我们会得到:
>"Portland"
正是我们首先,让localDataStorage为我们保护数据。
来源
2017-07-17 19:42:09
Mac
哇,谢谢!那正是我需要的。如果(window.localStorage.key(i)!=='stad'){(i = 0; i" + window.localStorage.key(i) + "“); } } –
Matt
2013-05-14 18:29:02