Here you can find the source of sha1(byte[] bytesOfMessage)
public static String sha1(byte[] bytesOfMessage)
//package com.java2s; /* /*from ww w . j a v a 2 s.c om*/ * SWRVE CONFIDENTIAL * * (c) Copyright 2010-2014 Swrve New Media, Inc. and its licensors. * All Rights Reserved. * * NOTICE: All information contained herein is and remains the property of Swrve * New Media, Inc or its licensors. The intellectual property and technical * concepts contained herein are proprietary to Swrve New Media, Inc. or its * licensors and are protected by trade secret and/or copyright law. * Dissemination of this information or reproduction of this material is * strictly forbidden unless prior written permission is obtained from Swrve. */ import android.util.Log; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static final String LOG_TAG = "SwrveSDK"; public static String sha1(byte[] bytesOfMessage) { if (bytesOfMessage.length == 0) { return null; } else { try { MessageDigest sha1 = MessageDigest.getInstance("SHA1"); byte[] hash = sha1.digest(bytesOfMessage); StringBuilder hexDigest = new StringBuilder(); for (int i = 0; i < hash.length; i++) { if ((0xFF & hash[i]) < 0x10) { hexDigest.append("0"); } hexDigest.append(Integer.toHexString(0xFF & hash[i])); } return hexDigest.toString(); } catch (NoSuchAlgorithmException nsae) { Log.wtf(LOG_TAG, "Couldn't find SHA1 - what a strange JVM", nsae); return ""; } } } }