Here you can find the source of SHAsum(byte[] convertme, boolean prefix, boolean uppercase)
public static String SHAsum(byte[] convertme, boolean prefix, boolean uppercase)
//package com.java2s; /*// w w w.jav a 2 s . com * Copyright 2014 scape. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Formatter; public class Main { public static String SHAsum(byte[] convertme, boolean prefix, boolean uppercase) { try { MessageDigest md = MessageDigest.getInstance("SHA-1"); String sha1 = byteArray2Hex(md.digest(convertme)); if (prefix) { return "sha1:" + sha1; } else { if (uppercase) { return sha1.toUpperCase(); } else { } return sha1; } } catch (NoSuchAlgorithmException e) { return ""; } } private static String byteArray2Hex(final byte[] hash) { Formatter formatter = new Formatter(); for (byte b : hash) { formatter.format("%02x", b); } return formatter.toString(); } }