Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: b63d37ac64
Fetching contributors…

Cannot retrieve contributors at this time

23 lines (17 sloc) 0.575 kB
# -*- coding: utf-8 -*-
import hashlib
import hmac
import urllib
def build_signature(parameters, secret):
"""
Builds the signature for the parameters and the body given.
Parameters is a list of tuples.
"""
message = urllib.urlencode(sorted(parameters))
return hmac.new(secret.encode('ascii'), message.encode('ascii'), hashlib.sha256).hexdigest()
def verify_signature(parameters, signature, secret):
"""
Verifies the signature
Parameters is a list of tuples.
"""
return build_signature(parameters, secret) == signature
Jump to Line
Something went wrong with that request. Please try again.