Created
June 15, 2014 21:46
-
-
Save benbahrenburg/5a8a25e7aa518ba55bd4 to your computer and use it in GitHub Desktop.
Secure Properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// storageType - This parameter is used to determine how the property values are stored. | |
// On iOS this can be PROPERTY_TYPE_PREFERENCES or PROPERTY_TYPE_KEYCHAIN. On Android, this value will always be PROPERTY_TYPE_PREFERENCES. | |
// | |
//To set this you use a property off the root of the module. The following are valid property values: | |
// PROPERTY_TYPE_PREFERENCES means the values are stored in the user preferences, just like Ti.App.Properties | |
// PROPERTY_TYPE_KEYCHAIN means these values are stored in the iOS keychain | |
// securityLevel - This parameter is used to determine the level of security that should be used. | |
// | |
// To set this you use a property off the root of the module. The following are valid property values: | |
// | |
// PROPERTY_SECURE_LEVEL_LOW - This means no encryption is applied. Because of this, you can only use the low level of security when the storageType is set to PROPERTY_TYPE_KEYCHAIN. This can only be used on iOS | |
// PROPERTY_SECURE_LEVEL_MED - This means the property values will be encrypted, but the property field names will still be in plain text | |
// PROPERTY_SECURE_LEVEL_HIGH - This means both property values and field names will be encrypted. | |
var securely = require('bencoding.securely'); | |
Ti.API.info("module is => " + securely); | |
Ti.API.info("Storing properties in preferences - Med Security Level"); | |
var properties = securely.createProperties({ | |
identifier:"Foo", | |
accessGroup:"Bar", | |
secret : "can't tell you", | |
storageType:securely.PROPERTY_TYPE_PREFERENCES, | |
securityLevel:securely.PROPERTY_SECURE_LEVEL_MED | |
}); | |
Ti.API.info("Storing properties in preference - HIGH Security Level"); | |
var properties = securely.createProperties({ | |
identifier:"Foo", | |
accessGroup:"Bar", | |
secret : "can't tell you", | |
storageType:securely.PROPERTY_TYPE_PREFERENCES, | |
securityLevel:securely.PROPERTY_SECURE_LEVEL_HIGH | |
}); | |
Ti.API.info("Storing properties in keyChain (only on iOS) - Low Security Level"); | |
var properties = securely.createProperties({ | |
identifier:"Foo", | |
accessGroup:"Bar", | |
secret : "can't tell you", | |
storageType:securely.PROPERTY_TYPE_KEYCHAIN, | |
securityLevel:securely.PROPERTY_SECURE_LEVEL_LOW | |
}); | |
Ti.API.info("Storing properties in keyChain (only on iOS) - Med Security Level"); | |
var properties = securely.createProperties({ | |
identifier:"Foo", | |
accessGroup:"Bar", | |
secret : "can't tell you", | |
storageType:securely.PROPERTY_TYPE_KEYCHAIN, | |
securityLevel:securely.PROPERTY_SECURE_LEVEL_MED | |
}); | |
Ti.API.info("Storing properties in keyChain (only on iOS) - High Security Level"); | |
var properties = securely.createProperties({ | |
identifier:"Foo", | |
accessGroup:"Bar", | |
secret : "can't tell you", | |
storageType:securely.PROPERTY_TYPE_KEYCHAIN, | |
securityLevel:securely.PROPERTY_SECURE_LEVEL_HIGH | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am getting error while using below code in iOS and how would i confirm that the data is getting stored on keychain and incase of android in keyStore.(https://github.com/benbahrenburg/Securely/blob/master/Android/documentation/properties.md)