Re: MD5 conversion problem
From: Peter Afonin (pva_at_speakeasy.net)
Date: 08/27/04
- Previous message: Bill Heckle: "Re: DPAPI Enterprise Services Example"
- In reply to: Joe Kaplan \(MVP - ADSI\): "Re: MD5 conversion problem"
- Next in thread: Joe Kaplan \(MVP - ADSI\): "Re: MD5 conversion problem"
- Reply: Joe Kaplan \(MVP - ADSI\): "Re: MD5 conversion problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 26 Aug 2004 23:40:37 -0700
Joe, I'm connecting an online store to the payment system. I need to pass
this string to this payment gateway, and it will return me another string
back, confirming that the payment was successful.
I contacted the techsupport of this gateway. They said that I don't have to
convert my string to Base64. I need to convert every byte to 16-bit number
or something like this. They don't use ASP.Net, so couldn't give me an exact
code. They said that it should look approximately like this:
StringBuilder sb = new StringBuilder();
for (int i=0;i<hash.Length;i++)
sb.Append(hash[i].ToString("x").PadLeft(2,'0'));
return sb.ToString();
How it should look in VB.Net?
Thank you,
Peter
"Joe Kaplan (MVP - ADSI)" <joseph.e.kaplan@removethis.accenture.com> wrote
in message news:OJQ8p$%23iEHA.3988@tk2msftngp13.phx.gbl...
> 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
> > > >
> > > >
> > >
> > >
> >
> >
>
>
- Previous message: Bill Heckle: "Re: DPAPI Enterprise Services Example"
- In reply to: Joe Kaplan \(MVP - ADSI\): "Re: MD5 conversion problem"
- Next in thread: Joe Kaplan \(MVP - ADSI\): "Re: MD5 conversion problem"
- Reply: Joe Kaplan \(MVP - ADSI\): "Re: MD5 conversion problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|
|