forked from aniyomiorg/aniyomi-extensions
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(en/fmovies): Update vrf & vidsrc extractor (aniyomiorg#2789)
- Loading branch information
Showing
6 changed files
with
186 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
src/en/fmovies/src/eu/kanade/tachiyomi/animeextension/en/fmovies/FMoviesHelper.kt
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
src/en/fmovies/src/eu/kanade/tachiyomi/animeextension/en/fmovies/FmoviesUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package eu.kanade.tachiyomi.animeextension.en.fmovies | ||
|
||
import android.util.Base64 | ||
import java.net.URLDecoder | ||
import javax.crypto.Cipher | ||
import javax.crypto.spec.SecretKeySpec | ||
|
||
class FmoviesUtils { | ||
|
||
fun vrfEncrypt(input: String): String { | ||
val rc4Key = SecretKeySpec("FWsfu0KQd9vxYGNB".toByteArray(), "RC4") | ||
val cipher = Cipher.getInstance("RC4") | ||
cipher.init(Cipher.DECRYPT_MODE, rc4Key, cipher.parameters) | ||
|
||
var vrf = cipher.doFinal(input.toByteArray()) | ||
vrf = Base64.encode(vrf, Base64.URL_SAFE or Base64.NO_WRAP) | ||
vrf = rot13(vrf) | ||
vrf = Base64.encode(vrf, Base64.URL_SAFE or Base64.NO_WRAP) | ||
vrf = vrfShift(vrf) | ||
val stringVrf = vrf.toString(Charsets.UTF_8) | ||
return java.net.URLEncoder.encode(stringVrf, "utf-8") | ||
} | ||
|
||
fun vrfDecrypt(input: String): String { | ||
var vrf = input.toByteArray() | ||
vrf = Base64.decode(vrf, Base64.URL_SAFE) | ||
|
||
val rc4Key = SecretKeySpec("8z5Ag5wgagfsOuhz".toByteArray(), "RC4") | ||
val cipher = Cipher.getInstance("RC4") | ||
cipher.init(Cipher.DECRYPT_MODE, rc4Key, cipher.parameters) | ||
vrf = cipher.doFinal(vrf) | ||
|
||
return URLDecoder.decode(vrf.toString(Charsets.UTF_8), "utf-8") | ||
} | ||
|
||
private fun rot13(vrf: ByteArray): ByteArray { | ||
for (i in vrf.indices) { | ||
val byte = vrf[i] | ||
if (byte in 'A'.code..'Z'.code) { | ||
vrf[i] = ((byte - 'A'.code + 13) % 26 + 'A'.code).toByte() | ||
} else if (byte in 'a'.code..'z'.code) { | ||
vrf[i] = ((byte - 'a'.code + 13) % 26 + 'a'.code).toByte() | ||
} | ||
} | ||
return vrf | ||
} | ||
|
||
private fun vrfShift(vrf: ByteArray): ByteArray { | ||
for (i in vrf.indices) { | ||
val shift = arrayOf(-4, -2, -6, 5, -2)[i % 5] | ||
vrf[i] = vrf[i].plus(shift).toByte() | ||
} | ||
return vrf | ||
} | ||
} |
Oops, something went wrong.