The keychain module provides methods for securely storing sensitive data on iOS and Android.
- Download the module ZIP file from the downloads section
and save it to either your project's root directory (the same directory as the
Resources
folder) or your Titanium SDK installation directory. - Edit
tiapp.xml
and add the following line to the<modules>
section, using the version number specified in the ZIP file name:
<module version="1.0" platform="android">com.obscure.keychain</module>
- Clean and rebuild your project.
Detailed instructions for installing modules can be found on the Appcelerator documentation site.
var keychain = require('com.obscure.keychain');
// NOTE passphrase is ignored on iOS
var keychainItem = keychain.createKeychainItem('mylogin', 'supersecretpassphrase');
// get values
alert('Your account name is ' + keychainItem.account);
// set values
keychainItem.account = 'pegli'; // username
keychainItem.valueData = 'correctbatteryhorsestaple'; // password