<s> import time <EOL> import hmac <EOL> import hashlib <EOL> def calculate_signature ( key , data , timestamp = None ) : <EOL> """<STR_LIT>""" <EOL> if timestamp is None : <EOL> timestamp = int ( time . time ( ) ) <EOL> message = str ( timestamp ) + '<STR_LIT>' . join ( "<STR_LIT>" % ( k , v ) for k , v in sorted ( data . items ( ) ) ) <EOL> signature = hmac . HMAC ( str ( key ) , message , hashlib . sha256 ) . hexdigest ( ) <EOL> return signature </s>
