Update AnimekaiDecoder.kt
This commit is contained in:
parent
d01574690d
commit
0cd37c2aa6
1 changed files with 25 additions and 16 deletions
|
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.animeextension.en.animekai
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.security.MessageDigest
|
|
||||||
import javax.crypto.Cipher
|
import javax.crypto.Cipher
|
||||||
import javax.crypto.spec.IvParameterSpec
|
import javax.crypto.spec.IvParameterSpec
|
||||||
import javax.crypto.spec.SecretKeySpec
|
import javax.crypto.spec.SecretKeySpec
|
||||||
|
@ -22,27 +21,37 @@ class AnimekaiDecoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun encrypt(text: String): String {
|
private fun encrypt(text: String): String {
|
||||||
val keyBytes = decodeBase64(SECRET)
|
return try {
|
||||||
val ivSpec = IvParameterSpec(IV.toByteArray(StandardCharsets.UTF_8))
|
val keyBytes = decodeBase64(SECRET)
|
||||||
val keySpec = SecretKeySpec(keyBytes, "AES")
|
val ivSpec = IvParameterSpec(IV.toByteArray(StandardCharsets.UTF_8))
|
||||||
|
val keySpec = SecretKeySpec(keyBytes, "AES")
|
||||||
|
|
||||||
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
|
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec)
|
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec)
|
||||||
|
|
||||||
val encrypted = cipher.doFinal(text.toByteArray(StandardCharsets.UTF_8))
|
val encrypted = cipher.doFinal(text.toByteArray(StandardCharsets.UTF_8))
|
||||||
return encodeBase64(encrypted)
|
encodeBase64(encrypted)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
"" // Return an empty string on failure
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun decrypt(base64Data: String): String {
|
private fun decrypt(base64Data: String): String {
|
||||||
val keyBytes = decodeBase64(SECRET)
|
return try {
|
||||||
val ivSpec = IvParameterSpec(IV.toByteArray(StandardCharsets.UTF_8))
|
val keyBytes = decodeBase64(SECRET)
|
||||||
val keySpec = SecretKeySpec(keyBytes, "AES")
|
val ivSpec = IvParameterSpec(IV.toByteArray(StandardCharsets.UTF_8))
|
||||||
|
val keySpec = SecretKeySpec(keyBytes, "AES")
|
||||||
|
|
||||||
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
|
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
|
||||||
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec)
|
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec)
|
||||||
|
|
||||||
val decrypted = cipher.doFinal(decodeBase64(base64Data))
|
val decrypted = cipher.doFinal(decodeBase64(base64Data))
|
||||||
return String(decrypted, StandardCharsets.UTF_8)
|
String(decrypted, StandardCharsets.UTF_8)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
"" // Return an empty string on failure
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -57,4 +66,4 @@ class AnimekaiDecoder {
|
||||||
return Base64.encodeToString(data, Base64.NO_WRAP)
|
return Base64.encodeToString(data, Base64.NO_WRAP)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue