forked from recloudstream/cloudstream
Update M3u8Helper.kt
This commit is contained in:
parent
11f16ad510
commit
b788da1bd4
1 changed files with 6 additions and 16 deletions
|
@ -5,6 +5,7 @@ import java.util.*
|
||||||
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
|
||||||
|
import kotlin.math.pow
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,29 +23,18 @@ class M3u8Helper {
|
||||||
} else null
|
} else null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toBytes16BigBecauseArjixIsDumb(n: Int): ByteArray {
|
fun toBytes16Big(n: Int): ByteArray {
|
||||||
var num = n
|
return ByteArray(16) {
|
||||||
val tail = ArrayList<Char>()
|
val fixed = n / 256.0.pow((15 - it))
|
||||||
while (num > 0) {
|
(maxOf(0, fixed.toInt()) % 256).toByte()
|
||||||
val b = num % 256
|
|
||||||
num /= 256
|
|
||||||
if (b > 0) {
|
|
||||||
tail.add(b.toChar())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val f = ArrayList<Char>()
|
|
||||||
for (i in 0 until 16 - tail.size) {
|
|
||||||
f.add(0x00.toChar())
|
|
||||||
}
|
|
||||||
tail.reversed().forEach { f.add(it) }
|
|
||||||
return f.map { it.toByte() }.toByteArray()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val defaultIvGen = sequence {
|
private val defaultIvGen = sequence {
|
||||||
var initial = 1
|
var initial = 1
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
yield(toBytes16BigBecauseArjixIsDumb(initial))
|
yield(toBytes16Big(initial))
|
||||||
++initial
|
++initial
|
||||||
}
|
}
|
||||||
}.iterator()
|
}.iterator()
|
||||||
|
|
Loading…
Reference in a new issue