'Generate the shasign for incoming or outgoing communications.
:param browse acquirer: the payment.acquirer browse record. It should
have a shakey in shaky out
:param string inout: \'in\' (odoo contacting buckaroo) or \'out\' (buckaroo
contacting odoo).
:param dict values: transaction values
:return string: shasign'

def _buckaroo_generate_digital_sign(self, inout, values):

    assert (inout in ('in', 'out'))
    assert (self.provider == 'buckaroo')
    keys = 'add_returndata    Brq_amount    Brq_culture    Brq_currency    Brq_invoicenumber    Brq_return    Brq_returncancel    Brq_returnerror    Brq_returnreject    brq_test    Brq_websitekey'.split()
    def get_value(key):
        if values.get(key):
            return values[key]
        return ''
    values = dict((values or {}))
    if (inout == 'out'):
        for key in values.keys():
            if (key.upper() == 'BRQ_SIGNATURE'):
                del values[key]
                break
        items = sorted(values.items(), key=(lambda (x, y): x.lower()))
        sign = ''.join((('%s=%s' % (k, urllib.unquote_plus(v))) for (k, v) in items))
    else:
        sign = ''.join((('%s=%s' % (k, get_value(k))) for k in keys))
    sign = (sign + self.brq_secretkey)
    if isinstance(sign, str):
        sign = urlparse.parse_qsl(sign)
    shasign = sha1(sign.encode('utf-8')).hexdigest()
    return shasign
