def passwd(passwd, user='', alg='sha1', realm=None):
 digest = ((hasattr(hashlib, alg) and getattr(hashlib, alg)) or None)
 if digest:
  if realm:
   digest.update('{0}:{1}:{2}'.format(user, realm, passwd))
  else:
   digest.update(passwd)
 return ((digest and digest.hexdigest()) or False)

def passwd ( passwd , user = '' , alg = 'sha1' , realm = None ) : digest = ( ( hasattr ( hashlib , alg ) and getattr ( hashlib , alg ) ) or None ) if digest : if realm : digest . update ( '{0}:{1}:{2}' . format ( user , realm , passwd ) ) else : digest . update ( passwd ) return ( ( digest and digest . hexdigest ( ) ) or False )
this function replaces the $catalina_home/bin/digest .