public static String hash(String string){
  try {
    MessageDigest sha1=MessageDigest.getInstance("SHA-1");
    sha1.update(string.getBytes("UTF-8"));
    return Base64.encode(sha1.digest());
  }
 catch (  Exception ex) {
    Debug debug=Debug.getInstance("amSDK");
    if (debug.warningEnabled()) {
      debug.warning("Hash.hash:",ex);
    }
    return null;
  }
}

public static String hash ( String string ) { try { MessageDigest sha1 = MessageDigest . getInstance ( "SHA-1" ) ; sha1 . update ( string . getBytes ( "UTF-8" ) ) ; return Base64 . encode ( sha1 . digest ( ) ) ; } catch ( Exception ex ) { Debug debug = Debug . getInstance ( "amSDK" ) ; if ( debug . warningEnabled ( ) ) { debug . warning ( "Hash.hash:" , ex ) ; } return null ; } }
generates a sha1 digest of the string and returns base64 encoded digest .
