try
{
//*-- create a message digest instance and compute the hash byte array
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.reset(); md.update(in.getBytes());
byte[] hash = md.digest();
//*--- Convert the hash byte array to hexadecimal format, pad hex chars with leading zeroes
//*--- to get a signature of consistent length (40) for all strings.
for (int i = 0; i < hash.length; i++)
{ out.append( fillin(Integer.toString(0xFF & hash[i], 16), 2, false, '0', 1) ); }