def hashPassword(sid, password): """ Create a SHA1-digest string of a session identifier and password. @param sid: The stream session identifier. @type sid: C{unicode}. @param password: The password to be hashed. @type password: C{unicode}. """ if not isinstance(sid, unicode): raise TypeError("The session identifier must be a unicode object") if not isinstance(password, unicode): raise TypeError("The password must be a unicode object") input = u"%s%s" % (sid, password) return sha1(input.encode('utf-8')).hexdigest()
def hashPassword(sid, password): """ Create a SHA1-digest string of a session identifier and password. @param sid: The stream session identifier. @type sid: C{unicode}. @param password: The password to be hashed. @type password: C{unicode}. """ if not isinstance(sid, unicode): raise TypeError("The session identifier must be a unicode object") if not isinstance(password, unicode): raise TypeError("The password must be a unicode object") input = u"%s%s" % (sid, password) return sha1(input.encode('utf-8')).hexdigest()
def _secureEnoughString(): """ Create a pseudorandom, 16-character string for use in secure filenames. """ return armor(sha1(randomBytes(64)).digest())[:16]
def _secureEnoughString(): """ Create a pseudorandom, 16-character string for use in secure filenames. """ return armor(sha1(randomBytes(64)).digest())[:16]