mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
parent
a2085202ec
commit
0077cebaa6
1 changed files with 9 additions and 4 deletions
|
@ -1,7 +1,6 @@
|
||||||
package com.lagradost.cloudstream3.extractors.helper
|
package com.lagradost.cloudstream3.extractors.helper
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.ErrorLoadingException
|
|
||||||
import com.lagradost.cloudstream3.base64DecodeArray
|
import com.lagradost.cloudstream3.base64DecodeArray
|
||||||
import com.lagradost.cloudstream3.base64Encode
|
import com.lagradost.cloudstream3.base64Encode
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils
|
import com.lagradost.cloudstream3.utils.AppUtils
|
||||||
|
@ -23,7 +22,12 @@ object AesHelper {
|
||||||
padding: String = HASH,
|
padding: String = HASH,
|
||||||
): String? {
|
): String? {
|
||||||
val parse = AppUtils.tryParseJson<AesData>(data) ?: return null
|
val parse = AppUtils.tryParseJson<AesData>(data) ?: return null
|
||||||
val (key, iv) = generateKeyAndIv(pass, parse.s.hexToByteArray()) ?: return null
|
val (key, iv) = generateKeyAndIv(
|
||||||
|
pass,
|
||||||
|
parse.s.hexToByteArray(),
|
||||||
|
ivLength = parse.iv.length / 2,
|
||||||
|
saltLength = parse.s.length / 2
|
||||||
|
) ?: return null
|
||||||
val cipher = Cipher.getInstance(padding)
|
val cipher = Cipher.getInstance(padding)
|
||||||
return if (!encrypt) {
|
return if (!encrypt) {
|
||||||
cipher.init(Cipher.DECRYPT_MODE, SecretKeySpec(key, "AES"), IvParameterSpec(iv))
|
cipher.init(Cipher.DECRYPT_MODE, SecretKeySpec(key, "AES"), IvParameterSpec(iv))
|
||||||
|
@ -40,7 +44,8 @@ object AesHelper {
|
||||||
salt: ByteArray,
|
salt: ByteArray,
|
||||||
hashAlgorithm: String = KDF,
|
hashAlgorithm: String = KDF,
|
||||||
keyLength: Int = 32,
|
keyLength: Int = 32,
|
||||||
ivLength: Int = 16,
|
ivLength: Int,
|
||||||
|
saltLength: Int,
|
||||||
iterations: Int = 1
|
iterations: Int = 1
|
||||||
): Pair<ByteArray,ByteArray>? {
|
): Pair<ByteArray,ByteArray>? {
|
||||||
|
|
||||||
|
@ -63,7 +68,7 @@ object AesHelper {
|
||||||
)
|
)
|
||||||
|
|
||||||
md.update(password)
|
md.update(password)
|
||||||
md.update(salt, 0, 8)
|
md.update(salt, 0, saltLength)
|
||||||
md.digest(generatedData, generatedLength, digestLength)
|
md.digest(generatedData, generatedLength, digestLength)
|
||||||
|
|
||||||
for (i in 1 until iterations) {
|
for (i in 1 until iterations) {
|
||||||
|
|
Loading…
Reference in a new issue