|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package com.fongmi.quickjs.method; |
|
|
|
|
|
|
|
|
|
import android.text.TextUtils; |
|
|
|
|
import android.util.Base64; |
|
|
|
|
|
|
|
|
|
import androidx.annotation.Keep; |
|
|
|
|
|
|
|
|
|
@ -20,6 +21,8 @@ import com.whl.quickjs.wrapper.QuickJSContext; |
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
import java.lang.reflect.Method; |
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Timer; |
|
|
|
|
@ -27,6 +30,10 @@ import java.util.TimerTask; |
|
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
|
import javax.crypto.Cipher; |
|
|
|
|
import javax.crypto.spec.IvParameterSpec; |
|
|
|
|
import javax.crypto.spec.SecretKeySpec; |
|
|
|
|
|
|
|
|
|
import okhttp3.Call; |
|
|
|
|
import okhttp3.FormBody; |
|
|
|
|
import okhttp3.Headers; |
|
|
|
|
@ -81,6 +88,26 @@ public class Global { |
|
|
|
|
return getProxy(true) + "&from=catvod" + "&header=" + URLEncoder.encode(ctx.stringify(headers)) + "&url=" + URLEncoder.encode(url); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Keep |
|
|
|
|
@JSMethod |
|
|
|
|
public String aesX(String mode, boolean encrypt, String input, boolean inBase64, String key, String iv, boolean outBase64) { |
|
|
|
|
try { |
|
|
|
|
byte[] keyBuf = key.getBytes(); |
|
|
|
|
if (keyBuf.length < 16) keyBuf = Arrays.copyOf(keyBuf, 16); |
|
|
|
|
byte[] ivBuf = iv == null ? new byte[0] : iv.getBytes(); |
|
|
|
|
if (ivBuf.length < 16) ivBuf = Arrays.copyOf(ivBuf, 16); |
|
|
|
|
Cipher cipher = Cipher.getInstance(mode + "Padding"); |
|
|
|
|
SecretKeySpec keySpec = new SecretKeySpec(keyBuf, "AES"); |
|
|
|
|
if (iv == null) cipher.init(encrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, keySpec); |
|
|
|
|
else cipher.init(encrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, keySpec, new IvParameterSpec(ivBuf)); |
|
|
|
|
byte[] inBuf = inBase64 ? Base64.decode(input, Base64.DEFAULT) : input.getBytes(StandardCharsets.UTF_8); |
|
|
|
|
return outBase64 ? Base64.encodeToString(cipher.doFinal(inBuf), Base64.DEFAULT) : new String(cipher.doFinal(inBuf), StandardCharsets.UTF_8); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Keep |
|
|
|
|
@JSMethod |
|
|
|
|
public Object setTimeout(JSFunction func, Integer delay) { |
|
|
|
|
|