Using the Java SHA-1 code

Hashing:

Using the SHA-1 code in Java is relatively simple. The SHA1 class contains a method called encode that accepts a String. An example of how to produce a single hash would be:

			String myString = "hello";
			String hashValue = SHA1.encode(myString);
		
After calling encode, hashValue would now contain the hash digest encoded in a String.

Code Output:

SHA-1 produces a 160 bit hash digest. This particular implementation of SHA uses what is known as "base-64" encoding to represent the output. Since not all characters in the 0-255 ASCII range are displayable, base-64 encoding spreads the data out. All bytes only contain one of 64 different values, all of which are displayable. The values (in order) are: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

Each character in the encoded digest represents 6 bits of the actual hash digest. A 'C' indicates the bits: 00 0010, a 'D' is 00 0011, a '/' is 11 1111, etc.