翰林优商.apk(点击下载) / a.java


package com.duoyou.task.pro.g;

import android.text.TextUtils;
import android.util.Base64;
import com.kuaishou.weapon.p0.b;
import java.security.Key;
import java.security.MessageDigest;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public class a {
    public static final IvParameterSpec d = new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
    public Key a;
    public IvParameterSpec b;
    public Cipher c;

    public a(String str, int i, String str2) {
        this.a = i == 256 ? new SecretKeySpec(a("SHA-256", str), b.b) : new SecretKeySpec(a("MD5", str), b.b);
        this.b = new IvParameterSpec(a("MD5", str2));
        a();
    }

    public static String b(String str) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        try {
            return new a("2e93588063b14bae", 128, "################").a(str);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static String c(String str) {
        a aVar = new a("2e93588063b14bae", 128, "################");
        try {
            byte[] bytes = str.getBytes("UTF-8");
            try {
                aVar.c.init(1, aVar.a, aVar.b);
                return new String(Base64.encode(aVar.c.doFinal(bytes), 0), "UTF-8");
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage());
            }
        } catch (Exception e2) {
            throw new RuntimeException(e2.getMessage());
        }
    }

    public String a(String str) {
        try {
            byte[] decode = Base64.decode(str, 0);
            try {
                this.c.init(2, this.a, this.b);
                return new String(this.c.doFinal(decode), "UTF-8");
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage());
            }
        } catch (Exception e2) {
            throw new RuntimeException(e2.getMessage());
        }
    }

    public final void a() {
        try {
            this.c = Cipher.getInstance(b.a);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    }

    public static byte[] a(String str, String str2) {
        try {
            byte[] bytes = str2.getBytes("UTF-8");
            try {
                MessageDigest instance = MessageDigest.getInstance(str);
                instance.update(bytes);
                return instance.digest();
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage());
            }
        } catch (Exception e2) {
            throw new RuntimeException(e2.getMessage());
        }
    }
}