.safeget - macmcmeans/localDataStorage GitHub Wiki
localDataStorage.safeget( keyName, [user scramble key] )
This method restores the obfuscated value stored under keyName returning the original value and data type. (If an Array was stored then an Array would be returned.) A user scramble key is optional, but if one were used to safeset the key, it must be supplied in order to retrieve the original value. When omitted, the global scramble key will be transparently used.
EXAMPLES:
● localData.safeget( 'safeKey1', [123456] ) --> 'obfuscated data here' ● localData.safeget( 'safeKey2', 'my secret scramble key' ) --> 99.97 ● localData.safeget( 'safeKey3', 6977221 ) --> Fri May 19 2017 10:04:17 GMT-0400 (Eastern Daylight Time) ● localData.safeget( 'safeKey4', {'a':['1']} ) --> true
Obviously, if you call safeget on an obfuscated key and supply the wrong scramble key then the returned value will be incorrect.
✨ The complement to this is safeset.
📝 NOTE: There is nothing to prevent you from safesetting a key and then, inadvertently or otherwise, retrieving the value with a method other than safeget. For instance, calling get on a key that was created using safeset will simply return the obfuscated value (not the original protected value).