2017年5月17日 星期三

Create a md5 hash from a string

Reference:

https://dzone.com/articles/android-snippet-making-md5

Code snippet:

public static String encryptByMd5Hash(String in) {
    String md5 = "";
    MessageDigest digest;
    try {
        digest = MessageDigest.getInstance("MD5");
        digest.reset();
        digest.update(in.getBytes());
        byte[] a = digest.digest();
        int len = a.length;
        StringBuilder sb = new StringBuilder(len << 1);
        for (int i = 0; i < len; i++) {
            sb.append(Character.forDigit((a[i] & 0xf0) >> 4, 16));
            sb.append(Character.forDigit(a[i] & 0x0f, 16));
        }
        md5 = sb.toString();
    } catch (NoSuchAlgorithmException e){
        e.printStackTrace();
    }
    return md5;
}

2017年5月9日 星期二

Fix "SecurityException: Binder invocation to an incorrect interface using in-app billing" when bind remote AIDL service

Reference:

http://blog.csdn.net/a1031359915/article/details/7785227

Description:

當 client app使用AIDL向 server app請求服務的時後,client app和 server app的 AIDL package name要一模一樣,否則在執行的時後,就會跳出 SecurityException: Binder invocation to an incorrect interface using in-app billing的錯誤訊息