#NEWLINE# def salt_n_hash( password , salt = None ) : #NEWLINE# #INDENT# "\n\tGenerate a salt and return in base64 encoding the hash of the\n\tpassword with the salt and the character '$' prepended to it.\n\t" #NEWLINE# salt = ( salt or b64 ( '' . join ( ( chr ( randint ( 0 , 255 ) ) for _ in range ( N_SALT ) ) ) ) ) #NEWLINE# return ( ( _ + '$' ) + b64 ( sha256 ( ( salt + password . encode ( 'ascii' ) ) ) . digest ( ) ) )