Created
December 4, 2025 07:55
-
-
Save Jaypatelbond/07db42c7cf7eb8b97ef0e4ab149410d9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class CryptoManager(context: Context) { | |
| private val aead = AndroidKeysetManager.Builder() | |
| .withSharedPref(context, "master_keyset", "master_key_preference") | |
| .withKeyTemplate(KeyTemplates.get("AES128_GCM_HKDF_4KB")) | |
| .withMasterKeyUri("android-keystore://master_key") | |
| .build() | |
| .keysetHandle | |
| .getPrimitive(StreamingAead::class.java) | |
| fun encrypt(outputStream: OutputStream): OutputStream { | |
| return aead.newEncryptingStream(outputStream, ByteArray(0)) | |
| } | |
| fun decrypt(inputStream: InputStream): InputStream { | |
| return aead.newDecryptingStream(inputStream, ByteArray(0)) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment