如何在AIR中加密本地数据(转)

    技术2024-10-27  27

    AIR中专门提供了一个存储区域用于存储加密的数据,类似于LocalSharedObject,但是是以加密形式存储的,这种数据的读取都封装在EncryptedLocalStore类中。主要使用下面两个方法:

    EncryptedLocalStore.setItem() EncryptedLocalStore.getItem() 这样,我们就可以将需要加密的数据保存到这个区域,需要的时候就到这里获取,示例代码:

    if(EncryptedLocalStore.getItem(“UserName”)!=null) { modelLocator.currentUser.name = String(EncryptedLocalStore.getItem(“UserName”)); modelLocator.currentUser.pass = String(EncryptedLocalStore.getItem(“UserPass”)); modelLocator.isRemember = true;}存储加密数据的示例代码:

    //如果用户选择记录密码,则将邮箱和密码保存到加密区域if(loginEvent.isRemember) { if(EncryptedLocalStore.getItem(“UserName”)==null) {  var nameByte:ByteArray = new ByteArray;  nameByte.writeUTFBytes(loginEvent.userName);  EncryptedLocalStore.setItem(“UserName”, nameByte);  var passByte:ByteArray = new ByteArray;  passByte.writeUTFBytes(loginEvent.passWord);  EncryptedLocalStore.setItem(“UserPass”, passByte); }} else { EncryptedLocalStore.removeItem(“UserName”); EncryptedLocalStore.removeItem(“UserPass”);}

    本文来自:http://blog.csdn.net/ld_flex/archive/2010/08/09/5798592.aspx

    最新回复(0)