Author |
Topic  |
|
faztech
Starting Member
1 Posts |
Posted - 05 May 2003 : 12:17:01
|
Hello 
I'm now integrating my existing website with Snitz Forum in order to make 'em work each other well. This includes cookies & session sharing and database integration. Practically it works well now.
Actually,my existing website is developed using Asp.Net.
I'm facing a real trouble when both of the SHA256 algorithm written in Asp.Net and Asp classic (but sexy) don't produce the same return hashed value as expected. I don't know which one of the algorithm to be blamed. (I'm not good at encryption philosophy).
Here I write also the test result, and both of the SHA256 code modules (Asp.net and classic Asp):
Test Result Take note that, "net" stands for the return hashed value returned by a set of ASP.net codes I downloaded from the Internet; and "asp" stands for the return hashed value returned by a set of classic ASP codes written in inc_sha256.asp. Peek at the underscores, those underscores denote the missing characters (originally the missing characters are NOT replaced by any space or symbol, all characters are next to each others)
quote: plainText: sejuk asp: ecfe4b807639198b2f6841b58efab94a5b95bcf4f799a208c7e078b10edf17ac net: ecfe4b807639198b2f6841b58efab94a5b95bcf4f799a2_8c7e078b1_edf17ac
plainText: sardin asp: bd440c58e4862658c81b08efb85b157a7847a9425ab1904e3028f7e9b1a5fd4d net: bd44_c58e4862658c81b_8efb85b157a7847a9425ab1904e3028f7e9b1a5fd4d
plainText: panas asp: 64bb5e6ac11d6e521d4188cb13ca038a7fc615ac6ae60792fd88654cd909f0df net: 64bb5e6ac11d6e521d4188cb13ca_38a7fc615ac6ae6_792fd88654cd9_9f0df
Note: For the asp hash return value, I picked up from Snitz_forums_2000.mdb database.
And here's the Asp.net code which I downloaded: quote:
<script runat="server"> Public Class HashLib Dim Encoder As New System.Text.ASCIIEncoding()
Public Function SHA1Hash(InputStr As String) As String Dim SHA1Hasher As New System.Security.Cryptography.SHA1CryptoServiceProvider() Return ToHexString(SHA1Hasher.ComputeHash(Encoder.GetBytes(InputStr))) End Function Public Function SHA256Hash(InputStr As String) As String Dim SHA256Hasher As New System.Security.Cryptography.SHA256Managed()
Return ToHexString(SHA256Hasher.ComputeHash(Encoder.GetBytes(InputStr))) End Function
Public Function SHA384Hash(InputStr As String) As String Dim SHA384Hasher As New System.Security.Cryptography.SHA384Managed()
Return ToHexString(SHA384Hasher.ComputeHash(Encoder.GetBytes(InputStr))) End Function Public Function SHA512Hash(InputStr As String) As String Dim SHA512Hasher As New System.Security.Cryptography.SHA512Managed() Return ToHexString(SHA512Hasher.ComputeHash(Encoder.GetBytes(InputStr))) End Function
Public Function MD5Hash(InputStr As String) As String Dim MD5Hasher As New System.Security.Cryptography.MD5CryptoServiceProvider()
Return ToHexString(MD5Hasher.ComputeHash(Encoder.GetBytes(InputStr))) End Function Private Function ToHexString(ByteArray As Byte()) As String Dim i As Integer For i = LBound(ByteArray) To Ubound(ByteArray) ToHexString &= Hex(ByteArray(i)) Next End Function End Class </script>
Above codes regards to: dotNET Hash Library 0.1 (HashLib.aspx) Copyright (c) 2003, Guo Xu (http://www.guox.tk) All rights reserved.
And for the Asp code, I need not to quote here because you guys can refer to inc_sha256.asp file.
So you guys can try this experiment and compare the results. I just wanna know, which one to be trusted? Maybe I'm kinda stupid for not knowing something you guys already know, but I'm sure Sha256 doesn't have any different model or make like BMW except their siblings SHA1, SHA384, SHA512  |
|
Asha
Starting Member
39 Posts |
Posted - 06 May 2003 : 22:02:40
|
In that output, everywhere there's a "_" in the net version, there's a "0" in the asp version. Could it be that the asp and net versions are producing the same results bit displaying them differently, e.g., there are print formatting differences?
The asp version (at least, one of them that I looked at) shows 64 hex digits, which equates to 256 bits, which is what you are supposed to get with SHA256. So probably the net version is displaying incorrectly, since it's putting out fewer than 64 hex digits.
Andrew
|
 |
|
|
Topic  |
|
|
|