Java SHA1 sha1(String src)

Here you can find the source of sha1(String src)

Description

sha

License

Open Source License

Declaration

public static String sha1(String src) throws Exception 

Method Source Code

//package com.java2s;
/**//from w  w w  . ja  v  a2 s  .  c  o  m
 * MezzoMedia Developed by Java <br>
 *
 * @Copyright 2010 by Solution Development Team, MezzoMedia, Inc. All rights reserved.
 *
 * This software is the confidential and proprietary information of MezzoMedia, Inc. <br>
 * You shall not disclose such Confidential Information and shall use it only <br>
 * in accordance with the terms of the license agreement you entered into with MezzoMedia.
 */

import java.security.MessageDigest;
import sun.misc.BASE64Encoder;

public class Main {
    public static String sha1(String src) throws Exception {
        MessageDigest md = MessageDigest.getInstance("SHA1"); //java.security.MessageDigest 
        byte[] hashBytes = md.digest(src.getBytes());
        BASE64Encoder b64e = new BASE64Encoder(); //sun.misc.BASE64Encoder 
        String hash = b64e.encode(hashBytes);
        return hash;
    }
}

Related

  1. sha1(String s)
  2. sha1(String s)
  3. sha1(String s)
  4. sha1(String s)
  5. sha1(String src)
  6. sha1(String src)
  7. sha1(String srcStr)
  8. SHA1(String str)
  9. SHA1(String str)