php hash hmac java,Python hmac.new与php hash_hmac不同

I would like to convert the following php code to python

Using the following input:

$securesecret = "5454545454545454646464646"

$hasinput = "user_transactionid=ZXeCLFdcoiyLyONd5Ub99cUOMsFPw9kkDRdfMJY0&vpc_AccessCode=74747474&vpc_Amount=200&vpc_CardExp=2012&vpc_CardNum=4242424242424242&vpc_CardSecurityCode=323&vpc_Command=pay&vpc_Currency=USD&vpc_Gateway=ssl&vpc_MerchTxnRef=22222&vpc_Merchant=52525252&vpc_OrderInfo=22222&vpc_ReturnURL=http://localhost/PHP/PHP_VPC_3DS 2.5 Party_DR.php&vpc_Version=1&vpc_card=Visa"

And this is the output using php and this is correct

D4A3343CB9E41BD328C67299BBCB602CDCE03E9D857C09F3BD94F2DC9112F2FE

However, using python method below with the same input above produces different output.

HMAC.new( force_bytes(securesecret), msg= hashInput.rstrip('&').encode('utf-8'), digestmod=SHA256).hexdigest().upper()

Output from python

7A935F1BE9CA69CD45C985BC2696A6DCFED9CFFD8DED86C5C8593CA974B80974

为什么这两种方法产生不同的输出?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值