Adding data to the encrypted local store

XXXXXXXXXXXXXXXXXXXXXXXXX

Use the setItem() static method of the EncryptedLocalStore class to store data in the local store. The data is stored in a hash table, using strings as keys, with the data stored as byte arrays.

For example, the following code stores a string in the encrypted local store:

var str = "Bob"; 
var bytes = new air.ByteArray(); 
bytes.writeUTFBytes(str); 
air.EncryptedLocalStore.setItem("firstName", bytes);

The third parameter of the setItem() method, the stronglyBound parameter, is optional. When this parameter is set to true, the encrypted local store provides a higher level of security, by binding the stored item to the storing AIR application’s digital signature and bits, as well as to the application’s publisher ID:

var str = "Bob"; 
var bytes = new air.ByteArray(); 
bytes.writeUTFBytes(str); 
air.EncryptedLocalStore.setItem("firstName", bytes, true);

For an item that is stored with stronglyBound set to true, subsequent calls to getItem() only succeed if the calling AIR application is identical to the storing application (if no data in files in the application directory have changed). If the calling AIR application is different from the storing application, the application throws an Error exception when you call getItem() for a strongly bound item. If you update your application, it will not be able to read strongly bound data previously written to the encrypted local store.

If the stronglyBound parameter is set to false (the default), only the publisher ID needs to stay the same for the application to read the data. The bits of the application may change (and they need to be signed by the same publisher), but they do not need to be the exact same bits as were in application that stored the data.