forked from brahmkshatriya/echo-extension-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d2165f
commit 418cf04
Showing
11 changed files
with
183 additions
and
175 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
Binary file not shown.
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,20 @@ | ||
{ | ||
"version": 3, | ||
"artifactType": { | ||
"type": "APK", | ||
"kind": "Directory" | ||
}, | ||
"applicationId": "dev.brahmkshatriya.echo.extension.deezer", | ||
"variantName": "release", | ||
"elements": [ | ||
{ | ||
"type": "SINGLE", | ||
"filters": [], | ||
"attributes": [], | ||
"versionCode": 1, | ||
"versionName": "1.0.0", | ||
"outputFile": "app-release.apk" | ||
} | ||
], | ||
"elementType": "File" | ||
} |
1 change: 0 additions & 1 deletion
1
app/src/main/java/dev/brahmkshatriya/echo/extension/Convertors.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
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
78 changes: 78 additions & 0 deletions
78
app/src/main/java/dev/brahmkshatriya/echo/extension/Utils.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,78 @@ | ||
package dev.brahmkshatriya.echo.extension | ||
|
||
import android.webkit.URLUtil | ||
import java.io.IOException | ||
import java.math.BigInteger | ||
import java.net.HttpURLConnection | ||
import java.net.URL | ||
import java.security.MessageDigest | ||
import javax.crypto.Cipher | ||
import javax.crypto.spec.IvParameterSpec | ||
import javax.crypto.spec.SecretKeySpec | ||
|
||
object Utils { | ||
private const val secret = "g4el58wc0zvf9na1" | ||
private val secretIvSpec = IvParameterSpec(byteArrayOf(0,1,2,3,4,5,6,7)) | ||
|
||
@Throws(IOException::class) | ||
fun getFinalURL(url: String): String { | ||
val con: HttpURLConnection = URL(url).openConnection() as HttpURLConnection | ||
con.instanceFollowRedirects = false | ||
con.connect() | ||
con.inputStream | ||
if (con.responseCode == HttpURLConnection.HTTP_MOVED_PERM || con.responseCode == HttpURLConnection.HTTP_MOVED_TEMP) { | ||
val redirectUrl: String = con.getHeaderField("Location") | ||
if (URLUtil.isValidUrl(redirectUrl)) return getFinalURL(redirectUrl) | ||
} | ||
return url | ||
} | ||
|
||
private fun bitwiseXor(firstVal: Char, secondVal: Char, thirdVal: Char): Char { | ||
return (BigInteger(byteArrayOf(firstVal.code.toByte())) xor | ||
BigInteger(byteArrayOf(secondVal.code.toByte())) xor | ||
BigInteger(byteArrayOf(thirdVal.code.toByte()))).toByte().toInt().toChar() | ||
} | ||
|
||
fun createBlowfishKey(trackId: String): String { | ||
val trackMd5Hex = trackId.toMD5() | ||
var blowfishKey = "" | ||
|
||
for (i in 0..15) { | ||
val nextChar = bitwiseXor(trackMd5Hex[i], trackMd5Hex[i + 16], secret[i]) | ||
blowfishKey += nextChar | ||
} | ||
|
||
return blowfishKey | ||
} | ||
|
||
fun decryptBlowfish(chunk: ByteArray, blowfishKey: String): ByteArray { | ||
val secretKeySpec = SecretKeySpec(blowfishKey.toByteArray(), "Blowfish") | ||
val thisTrackCipher = Cipher.getInstance("BLOWFISH/CBC/NoPadding") | ||
thisTrackCipher.init(Cipher.DECRYPT_MODE, secretKeySpec, secretIvSpec) | ||
return thisTrackCipher.update(chunk) | ||
} | ||
|
||
fun decryptBlowfishFinal(chunk: ByteArray, blowfishKey: String, isFinal: Boolean): ByteArray { | ||
val secretKeySpec = SecretKeySpec(blowfishKey.toByteArray(), "Blowfish") | ||
val thisTrackCipher = Cipher.getInstance("BLOWFISH/CBC/NoPadding") | ||
thisTrackCipher.init(Cipher.DECRYPT_MODE, secretKeySpec, secretIvSpec) | ||
return if (isFinal) { | ||
thisTrackCipher.doFinal(chunk) | ||
} else { | ||
thisTrackCipher.update(chunk) | ||
} | ||
} | ||
} | ||
|
||
private fun bytesToHex(bytes: ByteArray): String { | ||
var hexString = "" | ||
for (byte in bytes) { | ||
hexString += String.format("%02X", byte) | ||
} | ||
return hexString | ||
} | ||
|
||
fun String.toMD5(): String { | ||
val bytes = MessageDigest.getInstance("MD5").digest(this.toByteArray(Charsets.ISO_8859_1)) | ||
return bytesToHex(bytes).lowercase() | ||
} |
13 changes: 0 additions & 13 deletions
13
app/src/main/java/dev/brahmkshatriya/echo/extension/network/JsoupExtensions.kt
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
app/src/main/java/dev/brahmkshatriya/echo/extension/network/LoginInterceptor.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.