optimize ysp
This commit is contained in:
parent
cc2dc25e35
commit
d8fffbb402
|
@ -100,6 +100,7 @@ class Request(var context: Context) {
|
|||
val matchResult = regex.find(decodedString)
|
||||
var keyBytes = byteArrayOf()
|
||||
var ivBytes = byteArrayOf()
|
||||
|
||||
if (matchResult != null) {
|
||||
val (key, iv) = matchResult.destructured
|
||||
keyBytes = Base64.decode(key, Base64.DEFAULT)
|
||||
|
@ -107,9 +108,9 @@ class Request(var context: Context) {
|
|||
}
|
||||
tvModel.updateVideoUrlByYSP(
|
||||
liveInfo.data.playurl + "&revoi=" + encryptTripleDES(
|
||||
keyBytes,
|
||||
keyBytes + byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
|
||||
ivBytes
|
||||
)
|
||||
).uppercase()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -177,15 +178,15 @@ class Request(var context: Context) {
|
|||
}
|
||||
|
||||
private fun encryptTripleDES(key: ByteArray, iv: ByteArray): String {
|
||||
val plaintext =
|
||||
var plaintext =
|
||||
"""{"mver":"1","subver":"1.2","host":"www.yangshipin.cn/#/tv/home?pid=","referer":"","canvas":"YSPANGLE(Apple,AppleM1Pro,OpenGL4.1)"}"""
|
||||
return try {
|
||||
val keySpec = SecretKeySpec(key, "DESede")
|
||||
val ivSpec = IvParameterSpec(iv)
|
||||
val cipher = Cipher.getInstance("DESede/CBC/PKCS7Padding")
|
||||
val cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding")
|
||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec)
|
||||
val encryptedBytes = cipher.doFinal(plaintext.toByteArray())
|
||||
encryptedBytes.let { it -> it.joinToString("") { "%02x".format(it) } }
|
||||
return encryptedBytes.let { it -> it.joinToString("") { "%02x".format(it) } }
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
""
|
||||
|
|
|
@ -68,7 +68,7 @@ class YSP(var context: Context) {
|
|||
cnlid = tvModel.getTV().sid
|
||||
defn = "fhd"
|
||||
|
||||
guid = getGuid()
|
||||
// guid = getGuid()
|
||||
randStr = getRand()
|
||||
timeStr = getTimeStr()
|
||||
|
||||
|
@ -80,7 +80,6 @@ class YSP(var context: Context) {
|
|||
encryptor!!.encrypt(cnlid, timeStr, appVer, guid, platform)
|
||||
signature = getSignature()
|
||||
return """{"cnlid":"$cnlid","livepid":"$livepid","stream":"$stream","guid":"$guid","cKey":"$cKey","adjust":$adjust,"sphttps":"$sphttps","platform":"$platform","cmd":"$cmd","encryptVer":"$encryptVer","dtype":"$dtype","devid":"$devid","otype":"$otype","appVer":"$appVer","app_version":"$appVersion","rand_str":"$randStr","channel":"$channel","defn":"$defn","signature":"$signature"}"""
|
||||
|
||||
}
|
||||
|
||||
private fun getTimeStr(): String {
|
||||
|
@ -100,7 +99,7 @@ class YSP(var context: Context) {
|
|||
}
|
||||
|
||||
private fun getGuid(): String {
|
||||
// var guid = sharedPref?.getString("guid", "").toString()
|
||||
var guid = sharedPref?.getString("guid", "").toString()
|
||||
if (guid == "") {
|
||||
guid = generateGuid()
|
||||
with(sharedPref!!.edit()) {
|
||||
|
|
Loading…
Reference in New Issue