This is a simple library to encrypt and decrypt small amount of data such as passwords.
- Supports down to Android API 18
- Exposes only two methods:
Encrypt
andDecrypt
- No useless boilerplate
- Uses AndroidKeyStore to store the keys
- Fixed cryptographic algorithms
RSA
for18 <= API <= 22
and optionally also forAPI >= 23
(if you setforceAsymmetric = true
in initialization))AES
forAPI >= 23
- Init the library
Crypto.init(context, "keys_alias")
- Use the library
val helper = EncryptionHelper.getInstance()
val encrypted = helper.encrypt("some_text")
val decrypted = helper.decrypt(encrypted)
- More init configuration
- Algorithm
- Provider
- Transformation
- Resiliency to AndroidKeyStore keys deletion
- Recover from exception
- Other features I'm not yet aware
On API level lower than 21 keys might be deleted when user change the display's security mechanism (screen lock) Use with caution and only if losing your keys or not being able to recover the encrypted data are not critical for you.
Parts of the code are freely inspired by the Security Workshop Sample