Re: XML Encryption

From: William Stacey [MVP] (staceywREMOVE_at_mvps.org)
Date: 12/08/04

  • Next message: Bruce Wood: "Re: xsd validation"
    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
    > > >
    > > >
    > >
    >
    >
    

  • Next message: Bruce Wood: "Re: xsd validation"

    Relevant Pages

    • Re: SHA1 Hash question with large Files
      ... The docs say it is supported by Supported by the .NET Compact Framework. ... William Stacey [MVP] ... > How about using a Stream object to calculate a hash value for a file ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: XML Encryption
      ... Dave ... > William Stacey, MVP ... >> Imports System.Collections ...
      (microsoft.public.dotnet.xml)
    • Re: Decrypt
      ... MD5 is a one way hash. ... William Stacey, MVP ... > public static string DeCript ...
      (microsoft.public.dotnet.security)
    • MD5 for Large Files
      ... I would like to calculate an MD5 hash for very lage files. ... came across read the file into a byte array and apply the hash to that ... Imports System.Security.Cryptography ... Public Class Form1 ...
      (microsoft.public.dotnet.languages.vb)
    • Re: Serial Number Validation
      ... Your serial dialog will take the serial input and hash it and compare to the ... There are a few 3rd party ... license/serial checkers out there. ... William Stacey ...
      (microsoft.public.dotnet.languages.csharp)

  • Quantcast