【发布时间】:2015-03-05 18:27:57
【问题描述】:
我有一个密钥:zbPsRqhNg 需要在vb.net中编码
我正在使用以下来源:
Friend Overrides Function PostToLender(sData As String) As String
'' sData contains the XML to post
'' lendertier.ServiceURL is the URL to post to
'' so build a checksum from the XML data
Dim Secret As String = lendertier.Credential1 '' store the secret key in the tier's 1st credential
Dim hash As HMACSHA1 = New HMACSHA1()
hash.Key = UTF8.GetBytes(Secret)
Dim checksum As String = UTF8.GetString(hash.ComputeHash(UTF8.GetBytes(sData)))
'' append checksum to URL
lendertier.ServiceURL &= "&checksum=" & checksum
'' Complete normal processing
Return MyBase.PostToLender(sData)
End Function
这不起作用,结果不正确
checksum=%EF%BF%BD%EF%BF%BD&%EF%BF%BDg%EF%BF%BD*(%
应该是
6d91394d2b57ed448f45efcd2aeb773238b9055d
所以我尝试了,我认为我做错了:
Dim Secret As String = lendertier.Credential3 '' store the secret key in the tier's 1st credential
Dim hash As New SHA1CryptoServiceProvider()
HashCore = UTF8.GetBytes(Secret)
Dim checksum As String = UTF8.GetString(hash.ComputeHash(UTF8.GetBytes(sData)))
'' append checksum to URL
lendertier.ServiceURL &= "?checksum=" & checksum
没有工作,如果我能得到一点帮助,那就太好了。
【问题讨论】:
-
您可能希望对哈希的 Base64 编码进行 url 编码以将其传递到 URL:Passing base64 encoded strings in URL。