Re: SHA1 encoding differences with FormsAuthentication and SHA1CryptoServiceProvider
From: Super Julius (super_julius_at_yahoo.com)
Date: 05/12/04
- Next message: Bob: "using the key as the IV in RijndaelManaged, any problem?"
- Previous message: suresh d: "Authentication Problem when using Microsoft Application test center"
- In reply to: Hernan de Lahitte: "Re: SHA1 encoding differences with FormsAuthentication and SHA1CryptoServiceProvider"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 12 May 2004 09:21:29 -0700
Thanks Hernan for your answer.
You pointed right the issue. The problem was my convert to hex value
with Convert.ToString(b, 16).
I have not tested your solution as I fixed the issue just before your
post :-) by using String.Format
Anyway I guess this can be relevant to other folks...
Here is the new code with
private string Hash(string toHash)
{
string hashed = "";
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] hash =
sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(toHash));
foreach(byte b in hash)
hashed += String.Format("{0,2:X2}", b);
return hashed;
}
Cheers
Julius
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
- Next message: Bob: "using the key as the IV in RijndaelManaged, any problem?"
- Previous message: suresh d: "Authentication Problem when using Microsoft Application test center"
- In reply to: Hernan de Lahitte: "Re: SHA1 encoding differences with FormsAuthentication and SHA1CryptoServiceProvider"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|