def test_BuildSignature(self): req_dict = { "transType": "01", "sysReserved": "{aaa=a&bbb=b}", "merId": "888888888888888" } req_dict['signMethod'] = '01' req_dict['version'] = '5.0.0' sign_res = SDKUtil.buildSignature(req_dict, SDKConfig().signCertPath, SDKConfig().signCertPwd) check_sign = ( 'ClTZLArDgM7rE9KORsgEiCmaPo/8G4xg4SrTJAET9xcymexSSlYDjQMIfhvZ0qgtYzlI' '+fV/5/ZKbnpJD0R2qOsvhT9e+Xb2wZzJFeYJVDNBqlZZLXUcB2kU0ut2fKdHCAcWApoGA1Ks0d5s' '/CA4sp8ZdaejatHVuKnTHa8rgLallX9Gekxul538WtZoU4n4RNBEe2ythZnj5eUa' 'VFYdzzSQ6pAnlYfKzhby3p5/YFdZZHcYDbdrkQjS+ewgf6wQfFGu5X07BznqYjf6I6x25jPgidg6' 'OHE0m25uv2ksyZuEKwSM/WWUYOc0q/TF7XMhN1lpm3VZN8ePvIK5NPHPaA==') self.assertEqual(sign_res['signature'], check_sign) req_dict['signMethod'] = '01' req_dict['version'] = '5.1.0' sign_res = SDKUtil.buildSignature(req_dict, SDKConfig().signCertPath, SDKConfig().signCertPwd) check_sign = ( 'nCDm51Cju6CG0kvYNKJI0hlMMlPqKn2IftnBFWkeNftrNKxczLB2kAyASv6' 'Tr3PeOauGvgzv9KEpBBkZY1f7nhOuv/WfZVEHt4oWmxcd24TrEZ5dDtQb4t' 'amzUszl0p+TXDW4tqxzbwjjQ++acYtthLadhG44Cce0Lnno7LWIKDh1Fe6w' 'sMMAEXsJwZX7nIcskeymOTF98FopOt/RFsIHSJ4Z0UuqZ6gEOjPzSbqTgm2' 'SeAMFMmxMToUmY+doQHla5GNkI4VJox10LIZBlA8SRTwL6qt3kdHhFyP7mR' 'w2WbjzUA9kuqPtFhC7ucKJ5tFG1YmbnX5upg0Mg9h2UlofQ==') self.assertEqual(sign_res['signature'], check_sign) req_dict['signMethod'] = '11' sign_res = SDKUtil.buildSignature(req_dict, SDKConfig().signCertPath, SDKConfig().signCertPwd) check_sign = 'bda8e705fe9d67022f71e8ca14752abc402368ed142b3bc71837ac9dec99c18e' self.assertEqual(sign_res['signature'], check_sign) req_dict['signMethod'] = '12' sign_res = SDKUtil.buildSignature(req_dict, SDKConfig().signCertPath, SDKConfig().signCertPwd) check_sign = 'e3d147d4d1b835a3453c7f900acf8ad4370ebea0e750452a4a02db43c398af81' self.assertEqual(sign_res['signature'], check_sign)
def signBySecureKey(req, secureKey): ''' 签名,证书路径和密码从配置文件读 ''' return SDKUtil.buildSignature(req, secureKey=secureKey)
def sign(req, certPath=SDKConfig().signCertPath, certPwd=SDKConfig().signCertPwd): ''' 签名,证书路径和密码从配置文件读 ''' return SDKUtil.buildSignature(req, certPath, certPwd)
def signByCertInfo(req, certPath, certPwd): ''' 签名,证书路径和密码从配置文件读 ''' return SDKUtil.buildSignature(req, certPath, certPwd)