Java SHA1 sha1(String input)

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

Description

sha

License

Open Source License

Declaration

public static String sha1(String input) throws NoSuchAlgorithmException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static String sha1(String input) throws NoSuchAlgorithmException {
        MessageDigest mDigest = MessageDigest.getInstance("SHA1");
        byte[] result = mDigest.digest(input.getBytes());
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < result.length; i++) {
            sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
        }/*from  w  ww. j a  v a 2s  .  c om*/

        return sb.toString();
    }
}

Related

  1. SHA1(String decript)
  2. sha1(String input)
  3. sha1(String input)
  4. sha1(String input)
  5. sha1(String input)
  6. sha1(String input)
  7. sha1(String input)
  8. sha1(String input)
  9. sha1(String input)