in remote-robot/src/main/kotlin/com/intellij/remoterobot/encryption/AesEncryptor.kt [44:64]
override fun decrypt(text: String): String {
val input = try {
Base64.decode(text.trim { it <= ' ' }.toByteArray(charset("UTF8")))
} catch (e: DecoderException) {
throw IllegalStateException("Check properties specified: '$ENCRYPTION_ENABLED_KEY' = 'true', '$ENCRYPTION_PASSWORD_KEY' = 'YOUR SECRET PASSWORD'")
}
try {
synchronized(Cipher::class.java) {
val cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING")
cipher.init(Cipher.DECRYPT_MODE, key)
val plainText = ByteArray(cipher.getOutputSize(input.size))
var ptLength = cipher.update(input, 0, input.size, plainText, 0)
ptLength += cipher.doFinal(plainText, ptLength)
val decryptedString = String(plainText)
return decryptedString.trim { it <= ' ' }
}
} catch (e: BadPaddingException) {
throw IllegalStateException("Wrong password specified in '$ENCRYPTION_PASSWORD_KEY'")
}
}