PKCS7Padding is deprecated in Java 8
This commit is contained in:
parent
f53d947a13
commit
5d438daf83
1 changed files with 4 additions and 4 deletions
|
@ -17,10 +17,10 @@ class Aes {
|
||||||
val key = generateKey()
|
val key = generateKey()
|
||||||
val seed = SecureRandom().generateSeed(16)
|
val seed = SecureRandom().generateSeed(16)
|
||||||
val iv = IvParameterSpec(seed)
|
val iv = IvParameterSpec(seed)
|
||||||
encryptCipher = Cipher.getInstance("AES/CBC/PKCS7Padding").apply {
|
encryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding").apply {
|
||||||
init(Cipher.ENCRYPT_MODE, key, iv)
|
init(Cipher.ENCRYPT_MODE, key, iv)
|
||||||
}
|
}
|
||||||
decryptCipher = Cipher.getInstance("AES/CBC/PKCS7Padding").apply {
|
decryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding").apply {
|
||||||
init(Cipher.DECRYPT_MODE, key, iv)
|
init(Cipher.DECRYPT_MODE, key, iv)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -32,10 +32,10 @@ class Aes {
|
||||||
try {
|
try {
|
||||||
val key = SecretKeySpec(keyArr, "AES")
|
val key = SecretKeySpec(keyArr, "AES")
|
||||||
val iv = IvParameterSpec(ivArr)
|
val iv = IvParameterSpec(ivArr)
|
||||||
encryptCipher = Cipher.getInstance("AES/CBC/PKCS7Padding").apply {
|
encryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding").apply {
|
||||||
init(Cipher.ENCRYPT_MODE, key, iv)
|
init(Cipher.ENCRYPT_MODE, key, iv)
|
||||||
}
|
}
|
||||||
decryptCipher = Cipher.getInstance("AES/CBC/PKCS7Padding").apply {
|
decryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding").apply {
|
||||||
init(Cipher.DECRYPT_MODE, key, iv)
|
init(Cipher.DECRYPT_MODE, key, iv)
|
||||||
}
|
}
|
||||||
} catch (e: NoSuchAlgorithmException) {
|
} catch (e: NoSuchAlgorithmException) {
|
||||||
|
|
Loading…
Reference in a new issue