Loading...

Friday, 10 August 2012

SHA1 (Java)

public class Sha1{

   public Sha1Coding(){

     MessageDigest md = MessageDigest.getInstance("SHA1");
     md.reset();
     byte[] buffer = input.getBytes();
     md.update(buffer);
     byte[] digest = md.digest();

     String str = "";
     for (int i = 0; i < digest.length; i++) { 
        str +=  Integer.toString( ( digest[i] & 0xff ) + 0x100, 16).substring( 1 );
     }
    return str;
  }
}

No comments:

Post a Comment