Android SHA1 Hash Create encryptByUsingSha1(String passwd)

Here you can find the source of encryptByUsingSha1(String passwd)

Description

encrypt By Using Sha

Declaration

public static String encryptByUsingSha1(String passwd) 

Method Source Code

//package com.java2s;
import java.security.MessageDigest;

public class Main {
    public static String encryptByUsingSha1(String passwd) {
        try {//ww  w.j  av  a2  s .c  om
            MessageDigest md = MessageDigest.getInstance("SHA-1");
            String clearPassword = passwd;
            md.update(clearPassword.getBytes());
            byte[] digestedPassword = md.digest();
            return new String(digestedPassword);
        } catch (java.security.NoSuchAlgorithmException e) {
            System.out.println("Rats, SHA-1 doesn't exist");
            System.out.println(e.toString());
            return null;
        }

    }
}

Related

  1. calculateSHA1(byte[] data)
  2. sha1(byte[] bytesOfMessage)
  3. getCertificateSHA1(X509Certificate certificate)
  4. hmacSha1(byte[] value, byte[] key)
  5. computeSHAHash(String password)
  6. generateDigest(byte[] inputBytes)