titanium-sdk icon indicating copy to clipboard operation
titanium-sdk copied to clipboard

feat(android): use EncryptedSharedPreferences

Open m1ga opened this issue 1 year ago • 0 comments

fixes https://github.com/tidev/titanium-sdk/issues/13846

Adds Ti.App.Properties.useEncryption to store EncryptedSharedPreferences.

Test

Ti.App.Properties.setString("string", "plain value");
console.log("not encrypted - should be 'plain value': " + Ti.App.Properties.getString("string", "default"));

Ti.App.Properties.useEncryption = true;
Ti.App.Properties.setString("string", "secure value");
console.log("encrypted - should be 'secure value': " + Ti.App.Properties.getString("string", "default"));

Ti.App.Properties.useEncryption = false;
Ti.App.Properties.setString("string", "plain value 2");
console.log("not encrypted - should be 'plain value 2': " + Ti.App.Properties.getString("string", "default"));

Ti.App.Properties.useEncryption = true;
console.log("encrypted - should be 'secure value': " + Ti.App.Properties.getString("string", "default"));

Stores the values in an encrypted xml:

Screenshot_20230618_142738

Todo

  • [x] Extend test
  • [x] Docs

m1ga avatar Jun 18 '23 13:06 m1ga