Here you can find the source of sha1Hash(String s)
public static String sha1Hash(String s) throws NoSuchAlgorithmException, UnsupportedEncodingException
//package com.java2s; /******************************************************************************* * Copyright (c) 2011, 2016 Eurotech and/or its affiliates and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w . ja v a 2 s . c o m * Eurotech - initial API and implementation * *******************************************************************************/ import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import javax.xml.bind.DatatypeConverter; public class Main { public static String sha1Hash(String s) throws NoSuchAlgorithmException, UnsupportedEncodingException { MessageDigest cript = MessageDigest.getInstance("SHA-1"); cript.reset(); cript.update(s.getBytes("UTF8")); byte[] encodedBytes = cript.digest(); return DatatypeConverter.printBase64Binary(encodedBytes); } }