.safeset - macmcmeans/localDataStorage GitHub Wiki

localDataStorage.safeset( keyName, value, [user scramble key] )

This method stores value under keyName, creating a new key if necessary, where the key prefix is prepended to keyName, and value is stored obfuscated. A user scramble key is optional, and if omitted, the global scramble key will be used. Data types are preserved, so if an Array was set then an Array will be returned.

This will overwrite an existing value for keyName. When this happens, the prior value cannot be retrieved.

While value is obscured, it is not encrypted. This means, for example, that value is not padded to a certain amount to disguise its true length.

Scramble keys (user or global) may be set to any data type, just the same as value.

The value of the updated keyName is returned when this method executes.

EXAMPLES:

  • localData.safeset( 'safeKey1', 'obfuscated data here', [123456] )
  • localData.safeset( 'safeKey2', 99.97, 'my secret scramble key' )
  • localData.safeset( 'safeKey3', new Date(), 6977221 )
  • localData.safeset( 'safeKey4', true, {'a':['1']} )

🌐 This method may fire an event allowing you to monitor the key change.

✨ The complement to this is safeget.

🏿 The corresponding Memory Key method is _safeset.

📝 NOTE: To examine the obsfuscated data internally, retrieve keyName using forceget.