Skip to content

Instantly share code, notes, and snippets.

@yakivmospan
Created December 4, 2017 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yakivmospan/a26f5f4af4c5282ee5ec4f67e9da476e to your computer and use it in GitHub Desktop.
Save yakivmospan/a26f5f4af4c5282ee5ec4f67e9da476e to your computer and use it in GitHub Desktop.
// Create and Save asymmetric key
keyStoreWrapper.createAndroidKeyStoreSymmetricKey("MASTER_KEY")
// Get key from keyStore
val masterKey = keyStoreWrapper.getAndroidKeyStoreSymmetricKey("MASTER_KEY")
// Creates Cipher with symmetric transformation and provides encrypt and decrypt functions
val cipher = CipherWrapper("AES/CBC/PKCS7Padding")
// Encrypt message
val encryptedMessage = cipher.encrypt(message, masterKey)
// Decrypt message
val decryptedMessage = cipher.decrypt(encryptedMessage, masterKey)
// Ooops, InvalidKeyException: no IV set when one expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment