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]" <st***********@mvps.org> wrote in message
news:e8**************@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" <da***@dlownds.f2s.com> wrote in message
news:31*************@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