code: def passwd(passwd,
             user='',
             alg='sha1',
             realm=None):
      '''
      This function replaces the $CATALINA_HOME/bin/digest.sh script
      convert a clear-text password to the $CATALINA_BASE/conf/tomcat-users.xml
      format
  
      CLI Examples:
  
      .. code-block:: bash
  
          salt '*' tomcat.passwd secret
          salt '*' tomcat.passwd secret tomcat sha1
          salt '*' tomcat.passwd secret tomcat sha1 'Protected Realm'
      '''
      # Shouldn't it be SHA265 instead of SHA1?
      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 Falsf passwd(passwd,
             user='',
             alg='sha1',
             realm=None):
      '''
      This function replaces the $CATALINA_HOME/bin/digest.sh script
      convert a clear-text password to the $CATALINA_BASE/conf/tomcat-users.xml
      format
  
      CLI Examples:
  
      .. code-block:: bash
  
          salt '*' tomcat.passwd secret
          salt '*' tomcat.passwd secret tomcat sha1
          salt '*' tomcat.passwd secret tomcat sha1 'Protected Realm'
      '''
      # Shouldn't it be SHA265 instead of SHA1?
      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
docs: This function replaces the $CATALINA_HOME/bin/digest.sh script
      convert a clear-text password to the $CATALINA_BASE/conf/tomcat-users.xml
      format
  
      CLI Examples:
  
      .. code-block:: bash
  
          salt '*' tomcat.passwd secret
          salt '*' tomcat.passwd secret tomcat sha1
          salt '*' tomcat.passwd secret tomcat sha1 'Protected Realm'