コード例 #1
0
ファイル: systempayv2.py プロジェクト: tech62/Connecthys
 def signature(self, fields):
     self.logger.debug('got fields %s to sign' % fields)
     ordered_keys = sorted(
         [key for key in fields.keys() if key.startswith('vads_')])
     self.logger.debug('ordered keys %s' % ordered_keys)
     ordered_fields = [force_byte(fields[key]) for key in ordered_keys]
     secret = getattr(self, 'secret_%s' % fields['vads_ctx_mode'].lower())
     signed_data = '+'.join(ordered_fields)
     signed_data = '%s+%s' % (signed_data, force_byte(secret))
     self.logger.debug(u'generating signature on «%s»', signed_data)
     sign = hashlib.sha1(signed_data).hexdigest()
     self.logger.debug(u'signature «%s»', sign)
     return sign
コード例 #2
0
ファイル: systempayv2.py プロジェクト: tonioo/eopayment
 def signature(self, fields):
     self.logger.debug('got fields %s to sign' % fields)
     ordered_keys = sorted(
         [key for key in fields.keys() if key.startswith('vads_')])
     self.logger.debug('ordered keys %s' % ordered_keys)
     ordered_fields = [force_byte(fields[key]) for key in ordered_keys]
     secret = getattr(self, 'secret_%s' % fields['vads_ctx_mode'].lower())
     signed_data = '+'.join(ordered_fields)
     signed_data = '%s+%s' % (signed_data, force_byte(secret))
     self.logger.debug(
         u'generating signature on «%s»' % force_text(signed_data))
     sign = hashlib.sha1(force_byte(signed_data)).hexdigest()
     self.logger.debug(u'signature «%s»' % sign)
     return sign
コード例 #3
0
 def sha_sign(self, algo, key, params, keep):
     '''Ogone signature algorithm of query string'''
     values = params.items()
     values = [(a.upper(), b) for a, b in values]
     values = sorted(values)
     values = [u'%s=%s' % (a, b) for a, b in values if a in keep]
     tosign = key.join(values)
     tosign += key
     tosign = force_byte(tosign)
     hashing = getattr(hashlib, algo)
     return hashing(tosign).hexdigest().upper()
コード例 #4
0
ファイル: systempayv2.py プロジェクト: tonioo/eopayment
 def check_value(self, value):
     value = force_byte(value)
     if self.length and len(value) != self.length:
         return False
     if self.max_length and len(value) > self.max_length:
         return False
     if self.choices and value not in self.choices:
         return False
     if value == '':
         return True
     value = value.replace('.', '')
     if self.ptype == 'n':
         return value.isdigit()
     elif self.ptype == 'an':
         return value.isalnum()
     elif self.ptype == 'an-':
         return value.replace('-', '').isalnum()
     elif self.ptype == 'an;':
         return value.replace(';', '').isalnum()
     return True