
Offers utility functions for data encryption and decryption without key management, featuring `StringCipher`, `FileCipher`, and `AESCipher` for byte and stream manipulation.
Utility functions for data Encryption and Decryption
This library provides a couple of classes for easy encryption and decryption of data without key management for API 23 or above.
StringCipherFileCipherAESCipher (bytes or bytes stream manipulation)In your module build.gradle include the following dependency
implementation 'com.msignoretto.sekurity:sekurity:1.1.0'val appKeyStore = AppKeyStore(this)
val key = appKeyStore.getOrGenerate()
val stringCipher = StringCipher(cipher = AESCipher())
val plainText = "I'm A plain text"
val encryptedData = stringCipher.encrypt(key, plainText)
val plainTextResult = stringCipher.decrypt(key, encryptedData)
val appKeyStore = AppKeyStore(this)
val key = appKeyStore.getOrGenerate()
val text = "I'm a text in a file"
val file = File.createTempFile("test", null)
file.writeText(text, Charset.defaultCharset())
val fileOutput = File.createTempFile("testEncrypt", null)
val fileResult = File.createTempFile("testResult", null)
fileCipher.encrypt(key, file, fileOutput)
fileCipher.decrypt(key, fileOutput, fileResult)
encrypting bytes
val appKeyStore = AppKeyStore(this)
val key = appKeyStore.getOrGenerate()
val plainData = Random.Default.nextBytes(23)
val cipherData = cipher.encrypt(key, plainData)
val plainDataBack = cipher.decrypt(key, cipherData)
encrypting streams
val appKeyStore = AppKeyStore(this)
val key = appKeyStore.getOrGenerate()
val plainData = Random.nextBytes(23)
val plainStream = ByteArrayInputStream(plainData)
val encryptedStream = ByteArrayOutputStream(400)
val plainStreamResult = ByteArrayOutputStream(400)
cipher.encryptStream(key, plainStream, encryptedStream)
cipher.decryptStream(key, ByteArrayInputStream(encryptedStream.toByteArray()), plainStreamResult)
ParcelableCipher
Utility functions for data Encryption and Decryption
This library provides a couple of classes for easy encryption and decryption of data without key management for API 23 or above.
StringCipherFileCipherAESCipher (bytes or bytes stream manipulation)In your module build.gradle include the following dependency
implementation 'com.msignoretto.sekurity:sekurity:1.1.0'val appKeyStore = AppKeyStore(this)
val key = appKeyStore.getOrGenerate()
val stringCipher = StringCipher(cipher = AESCipher())
val plainText = "I'm A plain text"
val encryptedData = stringCipher.encrypt(key, plainText)
val plainTextResult = stringCipher.decrypt(key, encryptedData)
val appKeyStore = AppKeyStore(this)
val key = appKeyStore.getOrGenerate()
val text = "I'm a text in a file"
val file = File.createTempFile("test", null)
file.writeText(text, Charset.defaultCharset())
val fileOutput = File.createTempFile("testEncrypt", null)
val fileResult = File.createTempFile("testResult", null)
fileCipher.encrypt(key, file, fileOutput)
fileCipher.decrypt(key, fileOutput, fileResult)
encrypting bytes
val appKeyStore = AppKeyStore(this)
val key = appKeyStore.getOrGenerate()
val plainData = Random.Default.nextBytes(23)
val cipherData = cipher.encrypt(key, plainData)
val plainDataBack = cipher.decrypt(key, cipherData)
encrypting streams
val appKeyStore = AppKeyStore(this)
val key = appKeyStore.getOrGenerate()
val plainData = Random.nextBytes(23)
val plainStream = ByteArrayInputStream(plainData)
val encryptedStream = ByteArrayOutputStream(400)
val plainStreamResult = ByteArrayOutputStream(400)
cipher.encryptStream(key, plainStream, encryptedStream)
cipher.decryptStream(key, ByteArrayInputStream(encryptedStream.toByteArray()), plainStreamResult)
ParcelableCipher