/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  android.annotation.SuppressLint
 *  java.io.PrintStream
 *  java.lang.Exception
 *  java.lang.IllegalArgumentException
 *  java.lang.Integer
 *  java.lang.Object
 *  java.lang.String
 *  java.lang.System
 *  java.security.Key
 *  javax.crypto.Cipher
 *  javax.crypto.spec.SecretKeySpec
 */
package com.xinli.portalclient.util;

import android.annotation.SuppressLint;
import java.io.PrintStream;
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

@SuppressLint(value={"DefaultLocale"})
public class AESByKey {
    private static final String AES = "AES";

    /*
     * Enabled aggressive block sorting
     */
    public static String byte2hex(byte[] arrby) {
        String string2 = "";
        int n = 0;
        while (n < arrby.length) {
            String string3 = Integer.toHexString((int)(255 & arrby[n]));
            string2 = string3.length() == 1 ? String.valueOf((Object)string2) + "0" + string3 : String.valueOf((Object)string2) + string3;
            ++n;
        }
        return string2.toUpperCase();
    }

    public static int bytesToInt(byte[] arrby) {
        return 255 & arrby[0] | 65280 & arrby[1] << 8 | 16711680 & arrby[2] << 16 | -16777216 & arrby[3] << 24;
    }

    public static final String decrypt(String string2, String string3) {
        try {
            String string4 = new String(AESByKey.decrypt(AESByKey.hex2byte(string2.getBytes()), string3));
            return string4;
        }
        catch (Exception var3_3) {
            return null;
        }
    }

    public static byte[] decrypt(byte[] arrby, String string2) throws Exception {
        Cipher cipher = Cipher.getInstance((String)"AES");
        cipher.init(2, (Key)new SecretKeySpec(string2.getBytes(), "AES"));
        return cipher.doFinal(arrby);
    }

    public static final byte[] encrypt(String string2, String string3) {
        try {
            byte[] arrby = AESByKey.encrypt(string2.getBytes(), string3);
            return arrby;
        }
        catch (Exception var2_3) {
            return null;
        }
    }

    public static byte[] encrypt(byte[] arrby, String string2) throws Exception {
        Cipher cipher = Cipher.getInstance((String)"AES");
        cipher.init(1, (Key)new SecretKeySpec(string2.getBytes(), "AES"));
        return cipher.doFinal(arrby);
    }

    public static final String encryptToString(String string2, String string3) {
        try {
            String string4 = AESByKey.byte2hex(AESByKey.encrypt(string2.getBytes(), string3));
            return string4;
        }
        catch (Exception var2_3) {
            return null;
        }
    }

    public static byte[] hex2byte(byte[] arrby) {
        if (arrby.length % 2 != 0) {
            throw new IllegalArgumentException("\u957f\u5ea6\u4e0d\u662f\u5076\u6570");
        }
        byte[] arrby2 = new byte[arrby.length / 2];
        int n = 0;
        while (n < arrby.length) {
            String string2 = new String(arrby, n, 2);
            arrby2[n / 2] = (byte)Integer.parseInt((String)string2, (int)16);
            n += 2;
        }
        return arrby2;
    }

    public static void main(String[] arrstring) {
        byte[] arrby = AESByKey.encrypt("TEL=15829350859&SEQ=411D23BB-6A71-44C3-B468-123B643ED8BF", "0123456789012345");
        System.out.println("enCode=" + AESByKey.byte2hex(arrby));
    }

    public byte[] intToByte(int n) {
        byte[] arrby = new byte[]{(byte)(n & 255), (byte)((65280 & n) >> 8), (byte)((16711680 & n) >> 16), (byte)((-16777216 & n) >> 24)};
        return arrby;
    }
}

