This project is based on Hawk project with some changes. The default encryption was replaced by a new encryption method which is based on AndroidKeyStore. Also, the new encryption method inherits from Secrets Keeper project.
The below diagram illustrates steps of data storing which uses in this module.
You can implement your custom module based on the contracts for each sections of above diagram then inject it to module builder.
The below diagram illustrates flow of decision making in order to create keys.
SecureStorage.SecureStorageBuilder builder = new SecureStorage.SecureStorageBuilder(getApplicationContext()).build();
By default Symmetric key (AES) is used to encrypt/decrypt data. You can change it as below:
SecureStorage.SecureStorageBuilder builder = new SecureStorage.SecureStorageBuilder(getApplicationContext());
builder.setAlgorithm(AlgorithmType.ASYMMETRIC);
secureStorage = builder.build();
Also, you can add an LogInterceptor in order to log operations.
secureStorage = builder.setLogInterceptorModuleContract(new LogInterceptorModuleContract() {
@Override public void onLog(String message) {
Log.d("SecureStorage", message);
}
}).build();
secureStorage.put("Key", "Value");
secureStorage.get("key");
secureStorage.count();
secureStorage.contains("key");
secureStorage.delete("key");
The encryption module is based on AndroidKeyStore, thus it doesn't supported APIs below 18 because there is no infrastructure for AndroidKeyStore. In this situation(APIs below 18), the encryption module only (encrypt/decrypt)s data based on Base64.
By default, AES and RSA are used to encrypt/decrypt data.
There is no limit to encrypt/decrypt by Symmetric keys. If you want to use Asymmetric keys, the data size limit will be 245 bytes.