Fixes bug with Base64 encoding

This commit is contained in:
Vitor Pamplona 2023-07-24 16:28:41 -04:00
parent 25c40b89d7
commit 49fe1d0743

View File

@ -38,9 +38,9 @@ object CryptoUtils {
random.nextBytes(iv)
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
cipher.init(Cipher.ENCRYPT_MODE, SecretKeySpec(sharedSecret, "AES"), IvParameterSpec(iv))
val ivBase64 = Base64.getEncoder().encode(iv)
val ivBase64 = Base64.getEncoder().encodeToString(iv)
val encryptedMsg = cipher.doFinal(msg.toByteArray())
val encryptedMsgBase64 = Base64.getEncoder().encode(encryptedMsg)
val encryptedMsgBase64 = Base64.getEncoder().encodeToString(encryptedMsg)
return "$encryptedMsgBase64?iv=$ivBase64"
}