Jump to content

Java Encrypt a Password

- - - - -

  • Please log in to reply
No replies to this topic

#1
QuackWare

QuackWare

    Learning Programmer

  • Members
  • PipPipPip
  • 95 posts
Java Encrypt a Password



/** This code snippet was taken from freecodesnippets.com*/



   

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();

  }

}





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users