【问题标题】:Checksum using VB.Net SHA1使用 VB.Net SHA1 的校验和
【发布时间】: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

没有工作,如果我能得到一点帮助,那就太好了。

【问题讨论】:

标签: vb.net checksum sha


【解决方案1】:

认为这就是你要找的东西

Dim checksum As String = Convert.ToBase64String(hash.ComputeHash(UTF8.GetBytes(sData)))

【讨论】:

  • 嗨大卫,你能给我一个完整的解决方案,因为我在以下 HashCore = UTF8.GetBytes(Secret) 上遇到错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-03
  • 2012-06-10
  • 1970-01-01
  • 2017-06-01
相关资源
最近更新 更多