'Generate the shasign for incoming or outgoing communications.
:param string inout: \'in\' (odoo contacting ogone) or \'out\' (ogone
contacting odoo). In this last case only some
fields should be contained (see e-Commerce basic)
:param dict values: transaction values
:return string: shasign'

def _ogone_generate_shasign(self, inout, values):

    assert (inout in ('in', 'out'))
    assert (self.provider == 'ogone')
    key = getattr(self, ('ogone_shakey_' + inout))
    def filter_key(key):
        if (inout == 'in'):
            return True
        else:
            keys = ['AAVADDRESS', 'AAVCHECK', 'AAVMAIL', 'AAVNAME', 'AAVPHONE', 'AAVZIP', 'ACCEPTANCE', 'ALIAS', 'AMOUNT', 'BIC', 'BIN', 'BRAND', 'CARDNO', 'CCCTY', 'CN', 'COMPLUS', 'CREATION_STATUS', 'CURRENCY', 'CVCCHECK', 'DCC_COMMPERCENTAGE', 'DCC_CONVAMOUNT', 'DCC_CONVCCY', 'DCC_EXCHRATE', 'DCC_EXCHRATESOURCE', 'DCC_EXCHRATETS', 'DCC_INDICATOR', 'DCC_MARGINPERCENTAGE', 'DCC_VALIDHOURS', 'DIGESTCARDNO', 'ECI', 'ED', 'ENCCARDNO', 'FXAMOUNT', 'FXCURRENCY', 'IBAN', 'IP', 'IPCTY', 'NBREMAILUSAGE', 'NBRIPUSAGE', 'NBRIPUSAGE_ALLTX', 'NBRUSAGE', 'NCERROR', 'NCERRORCARDNO', 'NCERRORCN', 'NCERRORCVC', 'NCERRORED', 'ORDERID', 'PAYID', 'PAYIDSUB', 'PM', 'SCO_CATEGORY', 'SCORING', 'STATUS', 'SUBBRAND', 'SUBSCRIPTION_ID', 'TRXDATE', 'VC']
            return (key.upper() in keys)
    items = sorted(((k.upper(), v) for (k, v) in values.items()))
    sign = ''.join((('%s=%s%s' % (k, v, key)) for (k, v) in items if (v and filter_key(k))))
    sign = sign.encode('utf-8')
    shasign = sha1(sign).hexdigest()
    return shasign
