@@ -133,12 +133,12 @@ open class Rabbitstream : ExtractorApi() {
133133 return extractedKey to sources
134134 }
135135
136- private inline fun <reified T > decryptMapped (input : String , key : String ): T ? {
136+ private inline suspend fun <reified T > decryptMapped (input : String , key : String ): T ? {
137137 val decrypt = decrypt(input, key)
138138 return AppUtils .tryParseJson(decrypt)
139139 }
140140
141- private fun decrypt (input : String , key : String ): String {
141+ private suspend fun decrypt (input : String , key : String ): String {
142142 return decryptSourceUrl(
143143 generateKey(
144144 salt = base64DecodeArray(input).copyOfRange(8 , 16 ),
@@ -147,7 +147,7 @@ open class Rabbitstream : ExtractorApi() {
147147 )
148148 }
149149
150- private fun generateKey (salt : ByteArray , secret : ByteArray ): ByteArray {
150+ private suspend fun generateKey (salt : ByteArray , secret : ByteArray ): ByteArray {
151151 var key = md5(secret + salt)
152152 var currentKey = key
153153 while (currentKey.size < 48 ) {
@@ -157,18 +157,18 @@ open class Rabbitstream : ExtractorApi() {
157157 return currentKey
158158 }
159159
160- private fun md5 (input : ByteArray ): ByteArray =
161- md5Hasher.hashBlocking (input)
160+ private suspend fun md5 (input : ByteArray ): ByteArray =
161+ md5Hasher.hash (input)
162162
163163 @OptIn(DelicateCryptographyApi ::class )
164- private fun decryptSourceUrl (decryptionKey : ByteArray , sourceUrl : String ): String {
164+ private suspend fun decryptSourceUrl (decryptionKey : ByteArray , sourceUrl : String ): String {
165165 val cipherData = base64DecodeArray(sourceUrl)
166166 val encrypted = cipherData.copyOfRange(16 , cipherData.size)
167167 val keyBytes = decryptionKey.copyOfRange(0 , 32 )
168168 val ivBytes = decryptionKey.copyOfRange(32 , decryptionKey.size)
169169
170- val aesKey = aesCbc.keyDecoder().decodeFromByteArrayBlocking (AES .Key .Format .RAW , keyBytes)
171- val decryptedData = aesKey.cipher(padding = true ).decryptWithIvBlocking (ivBytes, encrypted)
170+ val aesKey = aesCbc.keyDecoder().decodeFromByteArray (AES .Key .Format .RAW , keyBytes)
171+ val decryptedData = aesKey.cipher(padding = true ).decryptWithIv (ivBytes, encrypted)
172172 return decryptedData.decodeToString()
173173 }
174174
0 commit comments