Here you can find the source of getHash(String credentials)
public static String getHash(String credentials)
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import sun.misc.BASE64Encoder; public class Main { public static String getHash(String credentials) { try {/*from ww w . j a v a 2 s . c o m*/ MessageDigest digest = MessageDigest.getInstance("SHA-1"); digest.reset(); byte[] input = digest.digest(credentials.getBytes()); return byteToBase64(input); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } /** * From a byte[] returns a base 64 representation * * @param data * byte[] * @return String * @throws IOException */ public static String byteToBase64(byte[] data) { BASE64Encoder endecoder = new BASE64Encoder(); return endecoder.encode(data); } }