Java tutorial
//package com.java2s; import android.util.Base64; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String getStringMD5(String key) { MessageDigest md5 = null; try { md5 = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } md5.update(key.getBytes()); //important: use Base64.URL_SAFE flag to avoid "+" and "/" return new String(Base64.encode(md5.digest(), Base64.URL_SAFE)); } }