SHA256 asp to asp.net problem
I am trying to post a webrequest to another site. That other site is in ASP. I am sending one of the querstings value in SHA256 ecnrypted format by following function.
The other website is checking the value in ASP format. These values don't match.
This is my .net 4.0 function for SHA256 conversion. I am passing input with value "60400doodle2699@yahoo.com2011082337D00F66CACACA5478AD9AE1E2A3D36D" for following function. Which returns "AFF83D621AE6FDCEA7B191A64F470EB288BF7B996EA00A9D6FBE444A48AD9508"
But the asp site expects value "e3ecd14c92a6ce3ed864e7e8feb9167c3d03开发者_如何学JAVA142fccdd3bf6a2cd62385c122977" for this same string, that's why my call is failing
public string EncryptSHA256Managed(string input )
{
UnicodeEncoding uEncode = new UnicodeEncoding() ;
byte[] bytClearString = uEncode.GetBytes(input);
SHA256Managed sha = new SHA256Managed() ;
string strHex = string.Empty;
byte[] hash = sha.ComputeHash(bytClearString) ;
string hex = BitConverter.ToString(hash);
hex = hex.Replace("-", "");
return hex;
}
First you need to use a known SHA256 implementation to figure out if either is correct; Firefox's Hackbar plugin has one, Notepad++'s Unicode version has one, Jacksum 1.7.0 will work if it's pasted into a file (beware extra characters), and there are Web versions http://www.webutils.pl/index.php?idx=sha1 http://hash.online-convert.com/sha256-generator
All of these show e3ecd14c92a6ce3ed864e7e8feb9167c3d03142fccdd3bf6a2cd62385c122977 as the correct result for the ANSI string "60400doodle2699@yahoo.com2011082337D00F66CACACA5478AD9AE1E2A3D36D".
Chances are, your UCS-2 "Unicode" implementation on the .NET side is what's causing different results.
What code are you using in classic ASP?
精彩评论