使用 VB.Net SHA1 的校验和
Checksum using VB.Net SHA1
我有一个密钥: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
都没有用,如果我能得到一点帮助就好了。
认为这就是您要找的东西
Dim checksum As String = Convert.ToBase64String(hash.ComputeHash(UTF8.GetBytes(sData)))
我有一个密钥: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
都没有用,如果我能得到一点帮助就好了。
认为这就是您要找的东西
Dim checksum As String = Convert.ToBase64String(hash.ComputeHash(UTF8.GetBytes(sData)))