我曹,我终于发现我的问题所在,原来是用了非正规的MD5加密!我一行行代码去对比结果,然后我发现只需要改动MD5加密的地方,就返回成功了!
sign = MD5(sign,32)
改为
sign =System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sign, "MD5"))
事情起源于我发现狐表的md5加密好像跟正规的不一样,于是我去搜论坛,发现这个帖子
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=60429&skin=0
里面介绍了MD5的32位加密的2个方法,
第一种MD5加密方法
把下面的代码写到全局代码,然后调用 msgbox(MD5("12345678", 32))
Public Function MD5(ByVal strSource As String, ByVal Code As Int16) As String
Dim dataToHash As Byte() = (New System.Text.ASCIIEncoding).GetBytes(strSource)
Dim hashvalue As Byte() = CType(System.Security.Cryptography.CryptoConfig.CreateFromName("MD5"), System.Security.Cryptography.HashAlgorithm).ComputeHash(dataToHash)
Dim ATR As String = ""
Dim i As Integer
Se lect Case Code
Case 16 '选择16位字符的加密结果
For i = 4 To 11
ATR &= Hex(hashvalue(i)).PadLeft(2, "0").ToLower
Next
Case 32 '选择32位字符的加密结果
For i = 0 To 15
ATR &= Hex(hashvalue(i)).PadLeft(2, "0").ToLower
Next
Case Else 'Code错误时,返回全部字符串,即32位字符
For i = 0 To 15
ATR &= Hex(hashvalue(i)).PadLeft(2, "0").ToLower
Next
End Sele ct
Return ATR
End Function
第二种MD5加密方法
msgbox(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("加密内容", "MD5"))
我随便尝试了一下,在大多数的情况下,这2个玩意结果一样
sign ="123213sfsdfsd"
output.show(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sign, "MD5"))
output.show( MD5(sign,32))
结果:
23D78377338174648057AF6CA0A32909
23D78377338174648057AF6CA0A32909
但是在加密内容很长很恶心下,这2个玩意加密出来的就不同了!
加密内容:
app_keydada00fe324e250fa4fbody{"origin_id":"20170828180639","city_name":"上海","city_code":"021","pay_for_supplier_fee":0.0,"fetch_from_receiver_fee":0.0,"deliver_fee":0.0,"tips":0,"info":"测试订单","cargo_price":10,"is_prepay":0,"expected_fetch_time":1503921999,"expected_finish_time":1503925599,"invoice_title":"测试","receiver_name":"测试","receiver_address":"上海市崇明岛","receiver_phone":"18588888888","receiver_tel":"18599999999","receiver_lat":31.2,"receiver_lng":121.5,"callback":"http://localhost:8081/receive/","shop_no":11047059}formatjsonsource_id73753timestamp1503914799v1.0
结果:
4084C516E52C4C0E39818613960E1F8E
E9493EA3D025612ABB9804CFAB534A25
第二行才是对的!这2个加密方法的玩意有啥不同?不是都是MD5的32位加密吗?
[此贴子已经被作者于2017/8/28 19:18:41编辑过]