Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun encrypt(cipherAlgorithm: String, plainText: ByteArray, key: Key): ByteArray? {
- return try {
- val cipher = Cipher.getInstance(cipherAlgorithm)
- cipher.init(Cipher.ENCRYPT_MODE, key)
- val cipherText = cipher.doFinal(plainText)
- cipherText
- } catch (exception: GeneralSecurityException) {
- exception.printStackTrace()
- null
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement