#NEWLINE# def get_hexdigest( algorithm , salt , raw_password ) : #NEWLINE# #INDENT# "\n    Returns a string of the hexdigest of the given plaintext password and salt\n    using the given algorithm ('md5', 'sha1' or 'crypt').\n    " #NEWLINE# ( raw_password , salt ) = ( smart_str ( raw_password ) , smart_str ( salt ) ) #NEWLINE# if ( algorithm == 'crypt' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import crypt #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# raise ValueError ( '"crypt" password algorithm not supported in this environment' ) #NEWLINE# #UNINDENT# return crypt . crypt ( raw_password , salt ) #NEWLINE# #UNINDENT# if ( algorithm == 'md5' ) : #NEWLINE# #INDENT# return md5_constructor ( ( salt + raw_password ) ) . hexdigest ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( algorithm == 'sha1' ) : #NEWLINE# #INDENT# return sha_constructor ( ( salt + raw_password ) ) . hexdigest ( ) #NEWLINE# #UNINDENT# #UNINDENT# raise ValueError ( 'Got unknown password algorithm type in password.' )