#NEWLINE# def calculate_digest( ip , timestamp , secret , userid , tokens , user_data , digest_algo ) : #NEWLINE# #INDENT# secret = maybe_encode ( secret ) #NEWLINE# userid = maybe_encode ( userid ) #NEWLINE# tokens = maybe_encode ( tokens ) #NEWLINE# user_data = maybe_encode ( user_data ) #NEWLINE# digest0 = digest_algo ( ( ( ( ( ( ( encode_ip_timestamp ( ip , timestamp ) + secret ) + userid ) + '\x00' ) + tokens ) + '\x00' ) + user_data ) ) . hexdigest ( ) #NEWLINE# digest = digest_algo ( ( digest0 + secret ) ) . hexdigest ( ) #NEWLINE# return digest