code: def get_hexdigest(algorithm, salt, raw_password):
      
      if isinstance(salt, unicode):
          salt = salt.encode('utf8')
      if algorithm == 'crypt':
          try:
              import crypt
          except ImportError:
              raise ValueError('"crypt" password algorithm not supported in this environment')
          return crypt.crypt(raw_password, salt)
      # The rest of the supported algorithms are supported by hashlib, but
      # hashlib is only available in Python 2.5.
      try:
          import hashlib
      except ImportError:
          if algorithm == 'md5':
              import md5
              return md5.new(salt + raw_password).hexdigest()
          elif algorithm == 'sha1':
              import sha
              return sha.new(salt + raw_password).hexdigest()
      else:
          if algorithm == 'md5':
              return hashlib.md5(salt + raw_password).hexdigest()
          elif algorithm == 'sha1':
              return hashlib.sha1(salt + raw_password).hexdigest()
      raise ValueError("Got unknown password algorithm type in password.")
docs: Returns a string of the hexdigest of the given plaintext password and salt
      using the given algorithm ('md5', 'sha1' or 'crypt').