feat(src/en): New Source: AsiaFlix (#2260)

This commit is contained in:
AwkwardPeak7
2023-09-26 14:47:51 +05:00
committed by GitHub
parent a11a15e2b3
commit 0e1e37e2e4
14 changed files with 509 additions and 0 deletions

View File

@ -94,6 +94,22 @@ object CryptoAES {
}
}
/**
* Encrypt using CryptoJS defaults compatible method.
*
* @param plainText plaintext
* @param keyBytes key as a bytearray
* @param ivBytes iv as a bytearray
*/
fun encrypt(plainText: String, keyBytes: ByteArray, ivBytes: ByteArray): String {
return try {
val cipherTextBytes = plainText.toByteArray()
encryptAES(cipherTextBytes, keyBytes, ivBytes)
} catch (e: Exception) {
""
}
}
/**
* Decrypt using CryptoJS defaults compatible method.
*
@ -114,6 +130,26 @@ object CryptoAES {
}
}
/**
* Encrypt using CryptoJS defaults compatible method.
*
* @param plainTextBytes encrypted text as a bytearray
* @param keyBytes key as a bytearray
* @param ivBytes iv as a bytearray
*/
private fun encryptAES(plainTextBytes: ByteArray, keyBytes: ByteArray, ivBytes: ByteArray): String {
return try {
val cipher = try {
Cipher.getInstance(HASH_CIPHER)
} catch (e: Throwable) { Cipher.getInstance(HASH_CIPHER_FALLBACK) }
val keyS = SecretKeySpec(keyBytes, AES)
cipher.init(Cipher.ENCRYPT_MODE, keyS, IvParameterSpec(ivBytes))
Base64.encodeToString(cipher.doFinal(plainTextBytes), Base64.DEFAULT)
} catch (e: Exception) {
""
}
}
/**
* Generates a key and an initialization vector (IV) with the given salt and password.
*