Re: MD5 conversion problem
From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 08/27/04
- Next message: JDP_at_Work: "Re: ASP Session Vars to ASP.Net"
- Previous message: Lucas Tam: "Re: ASP Session Vars to ASP.Net"
- In reply to: Peter Afonin: "Re: MD5 conversion problem"
- Next in thread: Peter Afonin: "Re: MD5 conversion problem"
- Reply: Peter Afonin: "Re: MD5 conversion problem"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 26 Aug 2004 23:39:55 -0500
What is giving you a "bad CRC" error? Is it the code below? That looks
like it should just return a base64 encoded MD5 hash of whatever string was
provided.
It isn't clear to me what you are trying to do or what the input is in the
funtion.
Joe K.
"Peter Afonin" <pva@speakeasy.net> wrote in message
news:eQeJri%23iEHA.3612@TK2MSFTNGP12.phx.gbl...
> Thank you, Joe.
>
> I've tried to change it like this:
>
> Dim hashedBytes As Byte()
> Dim md5 As New MD5CryptoServiceProvider
> Dim encoder As new UTF8Encoding
> hashedBytes = md5.ComputeHash(encoder.GetBytes(sCRC))
> sCRC = Convert.ToBase64String(md5.ComputeHash(hashedBytes))
> Me.crc.Value = sCRC
>
> Yes, the output string has changed:
>
> '<input type=hidden name=crc value="35r0XmeFIOXs5evTQM0q+w==">'+
>
> But I'm still getting a "bad crc" error.
>
> Peter
>
> "Joe Kaplan (MVP - ADSI)" <joseph.e.kaplan@removethis.accenture.com> wrote
> in message news:uoBsCL%23iEHA.4024@TK2MSFTNGP09.phx.gbl...
> > Why don't you try Convert.ToBase64String instead? Typically, you encode
> > binary data as a string with either Base64 or hex string encoding.
> >
> > Also, be careful about using ASCII encoding to convert the input string
to
> > binary. If it includes any non-ASCII characters, you'll be throwing
data
> > away. UTF8 is safer. Whatever you do, make sure you alway compute the
> hash
> > the same way if you are going to be using it for a comparison.
> >
> > HTH,
> >
> > Joe K.
> >
> > "Peter Afonin" <pva@speakeasy.net> wrote in message
> > news:eJWO769iEHA.3928@TK2MSFTNGP11.phx.gbl...
> > > Hello,
> > >
> > > I'm struggling with the string conversion to MD5 which I've never user
> > > before.
> > >
> > > I have a string that I need to encode which looks approximately like
> this:
> > >
> > >
> "pva:0.05:101214:pa7735tH:inv_desc=205308:shp_Email=petera_gudzon.net:lang
> > >
> >
>
=ru:shp_PaymentNo=20040825205308:shp_UserID=pva:shp_Price=2.95:shp_HostPlan=
> > > BU:shp_Term=2"
> > >
> > > I'm doing it this way:
> > >
> > > Dim hashedBytes As Byte()
> > > Dim md5 As New MD5CryptoServiceProvider
> > > Dim encoder As New ASCIIEncoding
> > > hashedBytes = md5.ComputeHash(encoder.GetBytes(sCRC))
> > > Dim sNewCRC as String = Convert.ToString(md5.ComputeHash(hashedBytes))
> > >
> > > It doesn't work. When I see the output on the page where I pass this
> > string,
> > > it looks like this:
> > >
> > > '<input type=hidden name=crc value="System.Byte[]">'+
> > >
> > > I don't know exactly how it should look like, but probably not like
> > > "System.Byte[]"
> > >
> > > I'm doing something wrong, but I don't know what.
> > >
> > > I would really appreciate your help.
> > >
> > > Thank you,
> > >
> > > Peter Afonin
> > >
> > >
> >
> >
>
>
- Next message: JDP_at_Work: "Re: ASP Session Vars to ASP.Net"
- Previous message: Lucas Tam: "Re: ASP Session Vars to ASP.Net"
- In reply to: Peter Afonin: "Re: MD5 conversion problem"
- Next in thread: Peter Afonin: "Re: MD5 conversion problem"
- Reply: Peter Afonin: "Re: MD5 conversion problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|