Re: XML Encryption
From: William Stacey [MVP] (staceywREMOVE_at_mvps.org)
Date: 12/08/04
- Previous message: SJD: "Re: XmlSerializer & FileNotFound (NOT the usual problem!)"
- In reply to: David Lownds: "Re: XML Encryption"
- Next in thread: David Lownds: "Re: XML Encryption"
- Reply: David Lownds: "Re: XML Encryption"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 8 Dec 2004 10:18:58 -0500
I think the diff is an "h" instead of "H" in your "s" var is different.
Only one bit can change the SHA hash result a lot.
-- William Stacey, MVP http://mvp.support.microsoft.com "David Lownds" <david@dlownds.f2s.com> wrote in message news:31npopF3ddc7rU1@individual.net... > Hi William, > > Thank you very much for your quick response. > > I'm not very familiar with c# so I've tried to convert your code to vb.net . > > My interpretation is > > Imports System > Imports System.Collections > Imports System.Security > Imports System.Security.Principal > Imports System.Security.Cryptography > Imports System.Text > > > Dim s As String > s = "<Hello>there</hello>" > Dim sha1 As New SHA1Managed > Dim encoding As UnicodeEncoding = New UnicodeEncoding > Dim hash As Byte() = encoding.UTF8.GetBytes(s) > Debug.WriteLine("Hash bytes:" + hash.Length.ToString) > Dim base64string As String > base64String = Convert.ToBase64String(hash) > Debug.WriteLine(base64string) > Debug.WriteLine("Len:" + base64string.Length.ToString) > > To which the result I get is > > Hash bytes:20 > PEhlbGxvPnRoZXJlPC9oZWxsbz4= > Len:28 > > This is different to your result. Not being an expert at this can you > confirm that what I've done is correct ? > > Many many thanks for your help on this. > > Dave > > > "William Stacey [MVP]" <staceywREMOVE@mvps.org> wrote in message > news:e89bJFO3EHA.3716@TK2MSFTNGP10.phx.gbl... > > string s = "<Hello>There</Hello>"; > > SHA1 sha1 = SHA1.Create(); > > byte[] hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(s)); > > Debug.WriteLine("Hash bytes:" + hash.Length); > > string base64String = Convert.ToBase64String(hash); > > Debug.WriteLine(base64String); > > Debug.WriteLine("Len:" + base64String.Length); > > > > Output > > ------------------- > > Hash bytes:20 > > kTOBvOCt/ARaUUzkd9sqwvNacqM= > > Len:28 > > > > -- > > William Stacey, MVP > > http://mvp.support.microsoft.com > > > > "David Lownds" <david@dlownds.f2s.com> wrote in message > > news:31mupgF3b5u48U1@individual.net... > > > Dear All, > > > > > > I need to do the following to an xml file in vb.net. > > > > > > - Read in the file > > > > > > - canonicalise (c14n) the XML document > > > - generate a 160-bit binary secure hash from the canonicalise XML > > > > > > using the SHA-1 algorithm > > > > > > - encode the binary data using base-64 to produce a 28 character string > > > > > > Can anyone provide me with some help ? I'm very stuck on this. > > > -- > > > Cheers > > > > > > Dave > > > > > > > > > >
- Previous message: SJD: "Re: XmlSerializer & FileNotFound (NOT the usual problem!)"
- In reply to: David Lownds: "Re: XML Encryption"
- Next in thread: David Lownds: "Re: XML Encryption"
- Reply: David Lownds: "Re: XML Encryption"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|