歌尔基办 v2.7.0版本的 MD5 值为:921fd7c85ec097e8cab7f049269b36e4

以下内容为反编译后的 EncodeUtils.java 源代码,内容仅作参考


package im.ovithmjoec.ui.hui.friendscircle.okhttphelper;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import android.util.Base64;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import kotlin.UByte;
public class EncodeUtils {
    public static String byte2Hex(byte[] bArr) {
        StringBuilder sb = new StringBuilder("");
        for (byte b : bArr) {
            String hexString = Integer.toHexString(b & UByte.MAX_VALUE);
            if (hexString.length() == 1) {
                hexString = "0" + hexString;
            }
            sb.append(hexString);
        }
        return sb.toString().trim();
    }

    public static byte[] hex2Byte(String str) {
        int length = str.length() / 2;
        byte[] bArr = new byte[length];
        for (int i = 0; i < length; i++) {
            int i2 = i * 2;
            int i3 = i2 + 1;
            bArr[i] = Byte.valueOf((byte) Integer.decode("0x" + str.substring(i2, i3) + str.substring(i3, i3 + 1)).intValue()).byteValue();
        }
        return bArr;
    }

    public static String imageToBase64(String str) {
        ?? isEmpty = TextUtils.isEmpty(str);
        String str2 = null;
        str2 = null;
        str2 = null;
        InputStream inputStream = null;
        try {
            try {
            } catch (Throwable th) {
                th = th;
                inputStream = isEmpty;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (isEmpty != 0) {
            return null;
        }
        try {
            isEmpty = new FileInputStream(str);
            try {
                byte[] bArr = new byte[isEmpty.available()];
                isEmpty.read(bArr);
                str2 = Base64.encodeToString(bArr, 0);
                isEmpty.close();
                isEmpty = isEmpty;
            } catch (Exception e2) {
                e = e2;
                e.printStackTrace();
                if (isEmpty != 0) {
                    isEmpty.close();
                    isEmpty = isEmpty;
                }
                return str2;
            }
        } catch (Exception e3) {
            e = e3;
            isEmpty = 0;
        } catch (Throwable th2) {
            th = th2;
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e4) {
                    e4.printStackTrace();
                }
            }
            throw th;
        }
        return str2;
    }

    public static Bitmap stringtoBitmap(String str) {
        if (str.startsWith("data:image")) {
            str = str.substring(str.indexOf("base64,") + 7);
        }
        try {
            byte[] decode = Base64.decode(str, 0);
            return BitmapFactory.decodeByteArray(decode, 0, decode.length);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}