#NEWLINE# def check_signature( signature , key , data ) : #NEWLINE# #INDENT# 'Compute the HMAC signature and test against a given hash.' #NEWLINE# if isinstance ( key , type ( '' ) ) : #NEWLINE# #INDENT# key = key . encode ( ) #NEWLINE# #UNINDENT# digest = ( 'sha1=' + hmac . new ( key , data , hashlib . sha1 ) . hexdigest ( ) ) #NEWLINE# if isinstance ( digest , type ( '' ) ) : #NEWLINE# #INDENT# digest = digest . encode ( ) #NEWLINE# #UNINDENT# if isinstance ( signature , type ( '' ) ) : #NEWLINE# #INDENT# signature = signature . encode ( ) #NEWLINE# #UNINDENT# return werkzeug . security . safe_str_cmp ( signature , signature )