Skip to content

Instantly share code, notes, and snippets.

@BDOMDev
Created June 26, 2019 08:58
Show Gist options
  • Save BDOMDev/80924c283eecafc373b2a5ec651c6d79 to your computer and use it in GitHub Desktop.
Save BDOMDev/80924c283eecafc373b2a5ec651c6d79 to your computer and use it in GitHub Desktop.
Decrypt a file
@Throws(Exception::class)
fun decrypt(yourKey: SecretKey, fileData: ByteArray): ByteArray {
val decrypted: ByteArray
val cipher = Cipher.getInstance("AES", "BC")
cipher.init(Cipher.DECRYPT_MODE, yourKey, IvParameterSpec(ByteArray(cipher.blockSize)))
decrypted = cipher.doFinal(fileData)
return decrypted
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment