Encrypt a password : SHA1 Secure Hash Algorithm « Security « Java Tutorial






public class Main {

  public static void main(String arg[]) throws Exception {
    System.out.println(encrypt("String"));
  }

  public static byte[] encrypt(String x) throws Exception {
    java.security.MessageDigest d = null;
    d = java.security.MessageDigest.getInstance("SHA-1");
    d.reset();
    d.update(x.getBytes());
    return d.digest();
  }
}








36.42.SHA1 Secure Hash Algorithm
36.42.1.Basic IO example using SHA1
36.42.2.PSS parameter recovery and encoding
36.42.3.Use SHA1
36.42.4.Encrypt a password