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:10121 4:pa7735tH:inv_ desc=205308:shp _Email=petera_g udzon.net:lang
=ru:shp_Payment No=200408252053 08:shp_UserID=p va:shp_Price=2. 95:shp_HostPlan =
BU:shp_Term=2"
I'm doing it this way:
Dim hashedBytes As Byte()
Dim md5 As New MD5CryptoServic eProvider
Dim encoder As New ASCIIEncoding
hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC))
Dim sNewCRC as String = Convert.ToStrin g(md5.ComputeHa sh(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.B yte[]">'+
I don't know exactly how it should look like, but probably not like
"System.Byt e[]"
I'm doing something wrong, but I don't know what.
I would really appreciate your help.
Thank you,
Peter Afonin 15 2414
Why don't you try Convert.ToBase6 4String 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" <pv*@speakeasy. net> wrote in message
news:eJ******** ******@TK2MSFTN GP11.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:10121 4:pa7735tH:inv_ desc=205308:shp _Email=petera_g udzon.net:lang
=ru:shp_Payment No=200408252053 08:shp_UserID=p va:shp_Price=2. 95:shp_HostPlan = BU:shp_Term=2"
I'm doing it this way:
Dim hashedBytes As Byte() Dim md5 As New MD5CryptoServic eProvider Dim encoder As New ASCIIEncoding hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) Dim sNewCRC as String = Convert.ToStrin g(md5.ComputeHa sh(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.B yte[]">'+
I don't know exactly how it should look like, but probably not like "System.Byt e[]"
I'm doing something wrong, but I don't know what.
I would really appreciate your help.
Thank you,
Peter Afonin
Thank you, Joe.
I've tried to change it like this:
Dim hashedBytes As Byte()
Dim md5 As New MD5CryptoServic eProvider
Dim encoder As new UTF8Encoding
hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC))
sCRC = Convert.ToBase6 4String(md5.Com puteHash(hashed Bytes))
Me.crc.Value = sCRC
Yes, the output string has changed:
'<input type=hidden name=crc value="35r0XmeF IOXs5evTQM0q+w= =">'+
But I'm still getting a "bad crc" error.
Peter
"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote
in message news:uo******** ********@TK2MSF TNGP09.phx.gbl. .. Why don't you try Convert.ToBase6 4String 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" <pv*@speakeasy. net> wrote in message news:eJ******** ******@TK2MSFTN GP11.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:10121 4:pa7735tH:inv_ desc=205308:shp _Email=petera_g udzon.net:lang
=ru:shp_Payment No=200408252053 08:shp_UserID=p va:shp_Price=2. 95:shp_HostPlan = BU:shp_Term=2"
I'm doing it this way:
Dim hashedBytes As Byte() Dim md5 As New MD5CryptoServic eProvider Dim encoder As New ASCIIEncoding hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) Dim sNewCRC as String = Convert.ToStrin g(md5.ComputeHa sh(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.B yte[]">'+
I don't know exactly how it should look like, but probably not like "System.Byt e[]"
I'm doing something wrong, but I don't know what.
I would really appreciate your help.
Thank you,
Peter Afonin
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" <pv*@speakeasy. net> wrote in message
news:eQ******** ********@TK2MSF TNGP12.phx.gbl. .. Thank you, Joe.
I've tried to change it like this:
Dim hashedBytes As Byte() Dim md5 As New MD5CryptoServic eProvider Dim encoder As new UTF8Encoding hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) sCRC = Convert.ToBase6 4String(md5.Com puteHash(hashed Bytes)) Me.crc.Value = sCRC
Yes, the output string has changed:
'<input type=hidden name=crc value="35r0XmeF IOXs5evTQM0q+w= =">'+
But I'm still getting a "bad crc" error.
Peter
"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote in message news:uo******** ********@TK2MSF TNGP09.phx.gbl. .. Why don't you try Convert.ToBase6 4String 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" <pv*@speakeasy. net> wrote in message news:eJ******** ******@TK2MSFTN GP11.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:10121 4:pa7735tH:inv_ desc=205308:shp _Email=petera_g udzon.net:lang
=ru:shp_Payment No=200408252053 08:shp_UserID=p va:shp_Price=2. 95:shp_HostPlan = BU:shp_Term=2"
I'm doing it this way:
Dim hashedBytes As Byte() Dim md5 As New MD5CryptoServic eProvider Dim encoder As New ASCIIEncoding hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) Dim sNewCRC as String = Convert.ToStrin g(md5.ComputeHa sh(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.B yte[]">'+
I don't know exactly how it should look like, but probably not like "System.Byt e[]"
I'm doing something wrong, but I don't know what.
I would really appreciate your help.
Thank you,
Peter Afonin
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.Leng th;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)" <jo************ *@removethis.ac centure.com> wrote
in message news:OJ******** ********@tk2msf tngp13.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" <pv*@speakeasy. net> wrote in message news:eQ******** ********@TK2MSF TNGP12.phx.gbl. .. Thank you, Joe.
I've tried to change it like this:
Dim hashedBytes As Byte() Dim md5 As New MD5CryptoServic eProvider Dim encoder As new UTF8Encoding hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) sCRC = Convert.ToBase6 4String(md5.Com puteHash(hashed Bytes)) Me.crc.Value = sCRC
Yes, the output string has changed:
'<input type=hidden name=crc value="35r0XmeF IOXs5evTQM0q+w= =">'+
But I'm still getting a "bad crc" error.
Peter
"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com>
wrote in message news:uo******** ********@TK2MSF TNGP09.phx.gbl. .. Why don't you try Convert.ToBase6 4String 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" <pv*@speakeasy. net> wrote in message news:eJ******** ******@TK2MSFTN GP11.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:10121 4:pa7735tH:inv_ desc=205308:shp _Email=petera_g udzon.net:lang >
=ru:shp_Payment No=200408252053 08:shp_UserID=p va:shp_Price=2. 95:shp_HostPlan = > BU:shp_Term=2" > > I'm doing it this way: > > Dim hashedBytes As Byte() > Dim md5 As New MD5CryptoServic eProvider > Dim encoder As New ASCIIEncoding > hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) > Dim sNewCRC as String =
Convert.ToStrin g(md5.ComputeHa sh(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.B yte[]">'+ > > I don't know exactly how it should look like, but probably not like > "System.Byt e[]" > > I'm doing something wrong, but I don't know what. > > I would really appreciate your help. > > Thank you, > > Peter Afonin > >
By the way, If you want to compute an MD5 ash on a pswd like string and get
the result in a string (eg for storing ashing in a dB), you could use this
wrapper method:
FormsAuthentica tion.HashPasswo rdForStoringInC onfigFile()
José
"Peter Afonin" <pv*@speakeasy. net> wrote in message
news:eJ******** ******@TK2MSFTN GP11.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:10121 4:pa7735tH:inv_ desc=205308:shp _Email=petera_g udzon.net:lang =ru:shp_Payment No=200408252053 08:shp_UserID=p va:shp_Price=2. 95:shp_HostPlan = BU:shp_Term=2"
I'm doing it this way:
Dim hashedBytes As Byte() Dim md5 As New MD5CryptoServic eProvider Dim encoder As New ASCIIEncoding hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) Dim sNewCRC as String = Convert.ToStrin g(md5.ComputeHa sh(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.B yte[]">'+
I don't know exactly how it should look like, but probably not like "System.Byt e[]"
I'm doing something wrong, but I don't know what.
I would really appreciate your help.
Thank you,
Peter Afonin
Thank you, I'll try.
Peter
"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:uI******** *****@TK2MSFTNG P12.phx.gbl... By the way, If you want to compute an MD5 ash on a pswd like string and
get the result in a string (eg for storing ashing in a dB), you could use this wrapper method: FormsAuthentica tion.HashPasswo rdForStoringInC onfigFile()
José "Peter Afonin" <pv*@speakeasy. net> wrote in message news:eJ******** ******@TK2MSFTN GP11.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:10121 4:pa7735tH:inv_ desc=205308:shp _Email=petera_g udzon.net:lang
=ru:shp_Payment No=200408252053 08:shp_UserID=p va:shp_Price=2. 95:shp_HostPlan = BU:shp_Term=2"
I'm doing it this way:
Dim hashedBytes As Byte() Dim md5 As New MD5CryptoServic eProvider Dim encoder As New ASCIIEncoding hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) Dim sNewCRC as String = Convert.ToStrin g(md5.ComputeHa sh(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.B yte[]">'+
I don't know exactly how it should look like, but probably not like "System.Byt e[]"
I'm doing something wrong, but I don't know what.
I would really appreciate your help.
Thank you,
Peter Afonin
Ah, this is the hex encoding thing I mentioned in my first post and didn't
provide an example for. You can either use the BitConverter class to
convert the byte[] to hex digits and then strip out the - characters it puts
in between or using something like my function called ConvertToOctetS tring
that you can do a Google groups search for that does this. It basically
just uses a StringBuilder and the X2 format code to loop over the bytes and
build the string.
Also, MAKE SURE that the vendor is calculating the MD5 of the data using the
same encoding that you are (UTF8, ACSII, UTF16, etc.) or else your input
byte array may be different and thus your hash will be different.
HTH,
Joe K.
"Peter Afonin" <pv*@speakeasy. net> wrote in message
news:ut******** ******@TK2MSFTN GP10.phx.gbl... 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.Leng th;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)" <jo************ *@removethis.ac centure.com> wrote in message news:OJ******** ********@tk2msf tngp13.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" <pv*@speakeasy. net> wrote in message news:eQ******** ********@TK2MSF TNGP12.phx.gbl. .. Thank you, Joe.
I've tried to change it like this:
Dim hashedBytes As Byte() Dim md5 As New MD5CryptoServic eProvider Dim encoder As new UTF8Encoding hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) sCRC = Convert.ToBase6 4String(md5.Com puteHash(hashed Bytes)) Me.crc.Value = sCRC
Yes, the output string has changed:
'<input type=hidden name=crc value="35r0XmeF IOXs5evTQM0q+w= =">'+
But I'm still getting a "bad crc" error.
Peter
"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote in message news:uo******** ********@TK2MSF TNGP09.phx.gbl. .. > Why don't you try Convert.ToBase6 4String 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" <pv*@speakeasy. net> wrote in message > news:eJ******** ******@TK2MSFTN GP11.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:10121 4:pa7735tH:inv_ desc=205308:shp _Email=petera_g udzon.net:lang > > >
=ru:shp_Payment No=200408252053 08:shp_UserID=p va:shp_Price=2. 95:shp_HostPlan = > > BU:shp_Term=2" > > > > I'm doing it this way: > > > > Dim hashedBytes As Byte() > > Dim md5 As New MD5CryptoServic eProvider > > Dim encoder As New ASCIIEncoding > > hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) > > Dim sNewCRC as String = Convert.ToStrin g(md5.ComputeHa sh(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.B yte[]">'+ > > > > I don't know exactly how it should look like, but probably not
like > > "System.Byt e[]" > > > > I'm doing something wrong, but I don't know what. > > > > I would really appreciate your help. > > > > Thank you, > > > > Peter Afonin > > > > > >
Thank you, Joe!
Peter
"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote
in message news:eB******** ******@TK2MSFTN GP11.phx.gbl... Ah, this is the hex encoding thing I mentioned in my first post and didn't provide an example for. You can either use the BitConverter class to convert the byte[] to hex digits and then strip out the - characters it
puts in between or using something like my function called ConvertToOctetS tring that you can do a Google groups search for that does this. It basically just uses a StringBuilder and the X2 format code to loop over the bytes
and build the string.
Also, MAKE SURE that the vendor is calculating the MD5 of the data using
the same encoding that you are (UTF8, ACSII, UTF16, etc.) or else your input byte array may be different and thus your hash will be different.
HTH,
Joe K.
"Peter Afonin" <pv*@speakeasy. net> wrote in message news:ut******** ******@TK2MSFTN GP10.phx.gbl... 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.Leng th;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)" <jo************ *@removethis.ac centure.com>
wrote in message news:OJ******** ********@tk2msf tngp13.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" <pv*@speakeasy. net> wrote in message news:eQ******** ********@TK2MSF TNGP12.phx.gbl. .. > Thank you, Joe. > > I've tried to change it like this: > > Dim hashedBytes As Byte() > Dim md5 As New MD5CryptoServic eProvider > Dim encoder As new UTF8Encoding > hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) > sCRC = Convert.ToBase6 4String(md5.Com puteHash(hashed Bytes)) > Me.crc.Value = sCRC > > Yes, the output string has changed: > > '<input type=hidden name=crc value="35r0XmeF IOXs5evTQM0q+w= =">'+ > > But I'm still getting a "bad crc" error. > > Peter > > "Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote > in message news:uo******** ********@TK2MSF TNGP09.phx.gbl. .. > > Why don't you try Convert.ToBase6 4String 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" <pv*@speakeasy. net> wrote in message > > news:eJ******** ******@TK2MSFTN GP11.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:10121 4:pa7735tH:inv_ desc=205308:shp _Email=petera_g udzon.net:lang > > > > > >
=ru:shp_Payment No=200408252053 08:shp_UserID=p va:shp_Price=2. 95:shp_HostPlan = > > > BU:shp_Term=2" > > > > > > I'm doing it this way: > > > > > > Dim hashedBytes As Byte() > > > Dim md5 As New MD5CryptoServic eProvider > > > Dim encoder As New ASCIIEncoding > > > hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) > > > Dim sNewCRC as String = Convert.ToStrin g(md5.ComputeHa sh(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.B yte[]">'+ > > > > > > I don't know exactly how it should look like, but probably not like > > > "System.Byt e[]" > > > > > > I'm doing something wrong, but I don't know what. > > > > > > I would really appreciate your help. > > > > > > Thank you, > > > > > > Peter Afonin > > > > > > > > > > > >
Hello Joe,
I found a code that should do exactly the same as in the example in my
previous message, but still doing something wrong, because the payment
gateway gives me a message that the string is bad. There is a chance that
the code itself is OK, but the data I put in is bad. But do you see anything
wrong with this code? I would appreciate your comments very much. Peter.
Dim enc As Encoder = System.Text.Enc oding.Unicode.G etEncoder()
Dim unicodeText() As Byte
unicodeText = System.Text.Uni codeEncoding.Un icode.GetBytes( sCRC)
enc.GetBytes(sC RC.ToCharArray( ), 0, sCRC.Length, unicodeText, _
0, True)
Dim oMD5 As New System.Security .Cryptography.M D5CryptoService Provider
Dim result() As Byte = oMD5.ComputeHas h(unicodeText)
Dim sb As New StringBuilder
Dim i As Integer = 0
For i = 0 To CType(result.Le ngth - 1, Integer)
sb.Append(resul t(i).ToString(" X").PadLeft( 2, "0"))
Next
sCRC = sb.ToString
"Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote
in message news:eB******** ******@TK2MSFTN GP11.phx.gbl... Ah, this is the hex encoding thing I mentioned in my first post and didn't provide an example for. You can either use the BitConverter class to convert the byte[] to hex digits and then strip out the - characters it
puts in between or using something like my function called ConvertToOctetS tring that you can do a Google groups search for that does this. It basically just uses a StringBuilder and the X2 format code to loop over the bytes
and build the string.
Also, MAKE SURE that the vendor is calculating the MD5 of the data using
the same encoding that you are (UTF8, ACSII, UTF16, etc.) or else your input byte array may be different and thus your hash will be different.
HTH,
Joe K.
"Peter Afonin" <pv*@speakeasy. net> wrote in message news:ut******** ******@TK2MSFTN GP10.phx.gbl... 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.Leng th;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)" <jo************ *@removethis.ac centure.com>
wrote in message news:OJ******** ********@tk2msf tngp13.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" <pv*@speakeasy. net> wrote in message news:eQ******** ********@TK2MSF TNGP12.phx.gbl. .. > Thank you, Joe. > > I've tried to change it like this: > > Dim hashedBytes As Byte() > Dim md5 As New MD5CryptoServic eProvider > Dim encoder As new UTF8Encoding > hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) > sCRC = Convert.ToBase6 4String(md5.Com puteHash(hashed Bytes)) > Me.crc.Value = sCRC > > Yes, the output string has changed: > > '<input type=hidden name=crc value="35r0XmeF IOXs5evTQM0q+w= =">'+ > > But I'm still getting a "bad crc" error. > > Peter > > "Joe Kaplan (MVP - ADSI)" <jo************ *@removethis.ac centure.com> wrote > in message news:uo******** ********@TK2MSF TNGP09.phx.gbl. .. > > Why don't you try Convert.ToBase6 4String 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" <pv*@speakeasy. net> wrote in message > > news:eJ******** ******@TK2MSFTN GP11.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:10121 4:pa7735tH:inv_ desc=205308:shp _Email=petera_g udzon.net:lang > > > > > >
=ru:shp_Payment No=200408252053 08:shp_UserID=p va:shp_Price=2. 95:shp_HostPlan = > > > BU:shp_Term=2" > > > > > > I'm doing it this way: > > > > > > Dim hashedBytes As Byte() > > > Dim md5 As New MD5CryptoServic eProvider > > > Dim encoder As New ASCIIEncoding > > > hashedBytes = md5.ComputeHash (encoder.GetByt es(sCRC)) > > > Dim sNewCRC as String = Convert.ToStrin g(md5.ComputeHa sh(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.B yte[]">'+ > > > > > > I don't know exactly how it should look like, but probably not like > > > "System.Byt e[]" > > > > > > I'm doing something wrong, but I don't know what. > > > > > > I would really appreciate your help. > > > > > > Thank you, > > > > > > Peter Afonin > > > > > > > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vladimir Khvostov |
last post by:
Hi,
We have some DB2 table on the host that has varchar(3200) columns that
are used to store binary data (I know that "varchar(3200) for bit
data" should have been used, by modifying host table is not an option
at this time).
I wrote a Win32 application, which is using DB2 Connect and ODBC to
pull the data from the host. I am passing SQL_C_BINARY as a 3rd
parameter in SQLBindCol() call, ::SQLBindCol(hStmt, nColNo + 1,
SQL_C_BINARY,...
|
by: Bjørn Augestad |
last post by:
Below is a program which converts a double to an integer in two
different ways, giving me two different values for the int. The basic
expression is 1.0 / (1.0 * 365.0) which should be 365, but one variable
becomes 364 and the other one becomes 365.
Does anyone have any insight to what the problem is?
Thanks in advance.
Bjørn
|
by: Steve Gough |
last post by:
Could anyone please help me to understand what is happening here? The
commented line produces an error, which is what I expected given that
there is no conversion defined from type double to type Test. I
expected the same error from the following line, but it compiles fine.
The double is silently truncated to an int and then fed in to the
implicit conversion operator. Why does this happen? Is there any way
that I can keep the implicit...
|
by: Steve Richter |
last post by:
here is a warning I am getting in a C++ .NET compile:
c:\SrNet\jury\JuryTest.cpp(55) : warning C4927: illegal conversion;
more than one user-defined conversion has been implicitly applied
while calling the constructor 'MyString::MyString(const
wchar_t *)'
c:\SrNet\jury\JuryTest.h(21) : see declaration of
'MyString::MyString'
The class "StringData" uses a, whatever you call it, operator const
|
by: VB Programmer |
last post by:
Simple ASP.NET 1 site. Opened solution in beta 2 of 2.0. Ran thru
conversion wizard and it states:
"Conversion Complete. There were some errors during conversion."
I view the conversion log and for the project there is 1 error...
http://localhost/Watersmark/
Conversion Issues - http://localhost/Watersmark/:
ERROR: Failed to backup website http://localhost/Watersmark/
| |
by: Påhl Melin |
last post by:
I have some problems using conversion operators in C++/CLI. In my
project I have two ref class:es Signal and SignalMask and I have an
conversion function in Signal to convert Signal:s to SignalMask:s. The
reason is I have a free function called WaitSignal that accepts av
SignalMask where Signals parameters are supposed to implicitly be
converted to SignalMask:s. I'm using the SignalMask class because I
want to be able to supply a logic...
|
by: Richard G. Riley |
last post by:
Would it be wrong to use "implicit casting" instead of the standards
"implicit conversion" when talking about implicit conversions between
certain data types. The standard mentions "explicit conversion" for a
cast operation
|
by: Dhirendra Singh |
last post by:
Hi,
The following C++ program is not compiling on my system.
#include <iostream>
using namespace std;
class complex {
double re, im;
public:
complex( ) :re(0), im(0) {}
|
by: Coleen |
last post by:
Hi All :-)
I'm new to this site. I've been trying to convert several .Net 2003 web applications and getting tons of conversion errors.
I found this site to help walk me through the conversion process: http://webproject.scottgu.com/VisualBasic/Migration2/Migration2.aspx
which is great, however, when I follow the steps in this tutorial exactly, I get 102 conversion errors! Almost all the errors have to do with ambiguous file names, but...
|
by: Nikola |
last post by:
Hello,
I'm writing a String class for C++ and I'm getting the following error
message when using operator:
test.cpp: In function ‘int main()’:
test.cpp:7: error: ISO C++ says that these are ambiguous, even though
the worst conversion for the first is better than the worst conversion
for the second:
string.h:19: note: candidate 1: char Types::String::operator(unsigned
int) const
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |