今天手机集成腾讯视频又有新需求了,全新的版本,全新的体验。需要我的MD5签名,以前还真没注意过,特此记录下。

public void printSignatureMD5() {
    try {
        PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);

        Log.e("getMD5MessageDigest", getMD5MessageDigest(packageInfo.signatures[0].toByteArray()));

    } catch (Exception e) {
        e.printStackTrace();
    }
}

public static String getMD5MessageDigest(byte[] bytes) {
    StringBuffer md5StringBuffer = new StringBuffer();
    try {
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
        messageDigest.reset();
        messageDigest.update(bytes);
        byte[] digest = messageDigest.digest();
        for (int i = 0; i < digest.length; i++) {
            String hexString = Integer.toHexString(digest[i] & 0xff);

            if (hexString.length() == 1)
                md5StringBuffer.append("0");

            md5StringBuffer.append(hexString);
        }
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    return md5StringBuffer.toString();
}
01-08 21:44