# Path: pagarme/resources/handler_request.py
# KEYS = {}


import binascii
import hmac
import re
from hashlib import sha1
from pagarme.resources.handler_request import KEYS


def validate(signature, payload, api_key=None):
    if api_key is None:
        key = KEYS['api_key'] if 'api_key' in KEYS else None
    else:
        key = api_key

    signature = re.sub('sha1=', '', signature)
    payload = payload.encode('utf-8')


# Path: pagarme/resources/handler_request.py
# KEYS = {}


# Path: pagarme/postback.py
import binascii
import hmac
import re
from hashlib import sha1
from pagarme.resources.handler_request import KEYS



def validate(signature, payload, api_key=None):
    if api_key is None:
        key = KEYS['api_key'] if 'api_key' in KEYS else None
    else:
        key = api_key

    signature = re.sub('sha1=', '', signature)
    payload = payload.encode('utf-8')


    if key not in(None, ''):