客户端存储机制的封装:secStore.js

jopen 10年前

secStore是在浏览器内客户端存储机制处理的一个简单包装。它被命名secStore.js,因为不仅这个插件能帮助你透明的存储和客户端的数据检索,还可选提供一个安全层使用SJCL(斯坦福大学的Javascript加密库)来加密上述的数据。

特性:

  • 支持HTML5 localStorage
  • 支持HTML5 sessionStorage
  • 支持Cookie
  • 支持AES 加密
  • Quota 支持(4K for cookies and 5MB for HTML5 mechanisms)

选项:

  • encrypt: {Boolean} Provide transparent symmetric encryption of saved data
  • data: {Mixed} Object, string, array or booleans of data to be saved
  • key: {String} Unique identifier used as storage key
  • passphrase: {String} User supplied passphrase
  • storage: {String} Storage engine to use; local, session or cookies

Default use

保存数据...

var storage = new secStore    , options = {      encrypt: true,      data: {        key: 'some data that is somewhat private'      }    };      storage.set(options, function(error, results){    if err throw err;    console.log(results);  });

取得数据...

var storage = new secStore    , options = {      encrypt: true    };      storage.get(options, function(error, results){    if err throw err;    console.log(results);  });

项目主页:http://www.open-open.com/lib/view/home/1416799342023