我试图弄清楚我的哈希出了什么问题。我收到一个错误“哈希值不匹配”作为肥皂响应。
服务器日志实际上抱怨这个哈希值?摘要价值
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="#_1">
<Transforms>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>l6kqP048t5INzJT3W8gxVSXplaE=</DigestValue>
</Reference>
So Now I am trying to compare this DigestValue with my code computed hash.
Not sure how else I could try to fix this
1) 导航到该元素。我可以这样做 GetBytes 吗?
XmlNode xmlnodeSigDigestValue = dc.DocumentElement.SelectSingleNode("/s:Envelope/s:Header/o:Security/sig:Signature", nsmgr).ChildNodes[0].ChildNodes[2].ChildNodes[2]";
string sSourceData = xmlnodeSigDigestValue.FirstChild.Value;//brings me to l6kqP048t5INzJT3W8gxVSXplaE
byte[] tmpHash = ASCIIEncoding.ASCII.GetBytes(sSourceData);
2)这是我请求的实际内容。所以它正在加密这个并签名
string ToCompare = @"ISA*00*00*ZZ*400034 *ZZ*100000 0507*1750*^*00501**IL*1*PELEYTAY*JAVIER~REF*SY*5~DMG*D8*1981*M~DTP*291*RD8*20130115-20130115~EQ*30~SE*14*0001~GE*1*456452~IEA*1*526208405~";
byte[] tmpNewHash;
tmpNewHash = new MD5CryptoServiceProvider().ComputeHash(tmpSource);
bool bEqual = false;
if (tmpNewHash.Length == tmpHash.Length)
{
int i=0;
while ((i < tmpNewHash.Length) && (tmpNewHash[i] == tmpHash[i]))
{
i += 1;
}
if (i == tmpNewHash.Length)
{
bEqual = true;
}
}
我可以比较这两个吗?我理解正确吗?我还能如何比较哈希?