Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. fun encrypt(cipherAlgorithm: String, plainText: ByteArray, key: Key): ByteArray? {
  2. return try {
  3. val cipher = Cipher.getInstance(cipherAlgorithm)
  4. cipher.init(Cipher.ENCRYPT_MODE, key)
  5. val cipherText = cipher.doFinal(plainText)
  6. cipherText
  7. } catch (exception: GeneralSecurityException) {
  8. exception.printStackTrace()
  9. null
  10. }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement