Back to project page gameapi-android.
The source code is released under:
MIT License
If you think the Android project gameapi-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.playtomic.android; // w ww . j a v a 2 s . c om import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import android.util.Base64; public class PEncode { public static String md5(String value) { MessageDigest algorithm; try { algorithm = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { return null; } algorithm.reset(); algorithm.update(value.getBytes()); byte messageDigest[] = algorithm.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { hexString.append(Integer.toString((messageDigest[i] & 0xff) + 0x100, 16).substring(1)); } return hexString.toString(); } /** * Encodes the string 'in' using 'flags'. Asserts that decoding * gives the same string. Returns the encoded string. */ public static String base64(String in) { String b64 = Base64.encodeToString(in.getBytes(), Base64.NO_WRAP); return b64; } }