Here you can find the source of generateHash(String serviceUri, String username, String password)
public static String generateHash(String serviceUri, String username, String password)
//package com.java2s; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String generateHash(String serviceUri, String username, String password) { StringBuilder hashkey = new StringBuilder(); String hash = null;/* ww w.ja va2 s .c o m*/ hashkey.append(serviceUri); hashkey.append(username); hashkey.append(password); try { MessageDigest sha = MessageDigest.getInstance("SHA-1"); sha.reset(); hash = hexEncode(sha.digest(hashkey.toString().getBytes())); } catch (NoSuchAlgorithmException e) { return hashkey.toString(); } return hash; } private static String hexEncode(byte[] aInput) { StringBuffer result = new StringBuffer(); char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; for (int idx = 0; idx < aInput.length; ++idx) { byte b = aInput[idx]; result.append(digits[(b & 0xf0) >> 4]); result.append(digits[b & 0x0f]); } return result.toString(); } }