473,396 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to generate an MD5 data from the string

Hello,

I've never been dealing with the security before. Could you please help me
to write a code to generate an MD5 data from a string? I've been using this
example from MSDN:

Function MD5hash(data() As Byte) As Byte()
' This is one implementation of the abstract class MD5.
Dim md5 As New MD5CryptoServiceProvider()

Dim result As Byte() = md5.ComputeHash(data)

Return result
End Function

but perhaps made a mistake converting string to byte and couldn't fix it.

My string looks like this:

sCRC = "avp:" & dblSum.ToString & ":" & CLng(Format(Now, "yyyyMMddHHmmss"))
_
& ":pa0107THOP:shp_UserID=" & sUser _
& ":shp_Price=" & dblPrice.ToString & ":shp_PaymentNo=" _
& CLng(Format(Now, "yyyyMMddHHmmss")) & ":shp_Term=" _
& sTerm & ":shp_Email=" & sEmail

I will be passing this parameter as a querystring.

I would really appreciate your help.

Thank you,

--
Peter Afonin
Nov 18 '05 #1
3 1368
And the exact problem is (how do you convert) ?

I would suggest
http://msdn.microsoft.com/library/de...simplified.asp

Patrice
--

"Peter Afonin" <pv*@speakeasy.net> a écrit dans le message de
news:OB**************@TK2MSFTNGP09.phx.gbl...
Hello,

I've never been dealing with the security before. Could you please help me
to write a code to generate an MD5 data from a string? I've been using this example from MSDN:

Function MD5hash(data() As Byte) As Byte()
' This is one implementation of the abstract class MD5.
Dim md5 As New MD5CryptoServiceProvider()

Dim result As Byte() = md5.ComputeHash(data)

Return result
End Function

but perhaps made a mistake converting string to byte and couldn't fix it.

My string looks like this:

sCRC = "avp:" & dblSum.ToString & ":" & CLng(Format(Now, "yyyyMMddHHmmss")) _
& ":pa0107THOP:shp_UserID=" & sUser _
& ":shp_Price=" & dblPrice.ToString & ":shp_PaymentNo=" _
& CLng(Format(Now, "yyyyMMddHHmmss")) & ":shp_Term=" _
& sTerm & ":shp_Email=" & sEmail

I will be passing this parameter as a querystring.

I would really appreciate your help.

Thank you,

--
Peter Afonin

Nov 18 '05 #2
Thank you, Patrice.

I'll try this, if it doesn't work I'll post my conversion here.

Peter

"Patrice" <no****@nowhere.com> wrote in message
news:OL*************@TK2MSFTNGP09.phx.gbl...
And the exact problem is (how do you convert) ?

I would suggest
http://msdn.microsoft.com/library/de...simplified.asp
Patrice
--

"Peter Afonin" <pv*@speakeasy.net> a écrit dans le message de
news:OB**************@TK2MSFTNGP09.phx.gbl...
Hello,

I've never been dealing with the security before. Could you please help me to write a code to generate an MD5 data from a string? I've been using

this
example from MSDN:

Function MD5hash(data() As Byte) As Byte()
' This is one implementation of the abstract class MD5.
Dim md5 As New MD5CryptoServiceProvider()

Dim result As Byte() = md5.ComputeHash(data)

Return result
End Function

but perhaps made a mistake converting string to byte and couldn't fix it.
My string looks like this:

sCRC = "avp:" & dblSum.ToString & ":" & CLng(Format(Now,

"yyyyMMddHHmmss"))
_
& ":pa0107THOP:shp_UserID=" & sUser _
& ":shp_Price=" & dblPrice.ToString & ":shp_PaymentNo=" _
& CLng(Format(Now, "yyyyMMddHHmmss")) & ":shp_Term=" _
& sTerm & ":shp_Email=" & sEmail

I will be passing this parameter as a querystring.

I would really appreciate your help.

Thank you,

--
Peter Afonin


Nov 18 '05 #3
PL

The absolute simplest way is to use:

string md5= System.Web.Security.FormsAuthentication.HashPasswo rdForStoringInConfigFile( str,"MD5");

where str is your string you want to computer the hash from and the last argument can
be "MD5" or "SHA1"

For more info look this up in the docs.

PL.
"Peter Afonin" <pv*@speakeasy.net> wrote in message news:OB**************@TK2MSFTNGP09.phx.gbl...
Hello,

I've never been dealing with the security before. Could you please help me
to write a code to generate an MD5 data from a string? I've been using this
example from MSDN:

Function MD5hash(data() As Byte) As Byte()
' This is one implementation of the abstract class MD5.
Dim md5 As New MD5CryptoServiceProvider()

Dim result As Byte() = md5.ComputeHash(data)

Return result
End Function

but perhaps made a mistake converting string to byte and couldn't fix it.

My string looks like this:

sCRC = "avp:" & dblSum.ToString & ":" & CLng(Format(Now, "yyyyMMddHHmmss"))
_
& ":pa0107THOP:shp_UserID=" & sUser _
& ":shp_Price=" & dblPrice.ToString & ":shp_PaymentNo=" _
& CLng(Format(Now, "yyyyMMddHHmmss")) & ":shp_Term=" _
& sTerm & ":shp_Email=" & sEmail

I will be passing this parameter as a querystring.

I would really appreciate your help.

Thank you,

--
Peter Afonin

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Scott M. Lyon | last post by:
Quick (hopefully easy) question for you guys. What is going to be the quickest/easiest way to generate XML from VB.NET? Note: I don't mean an XML file, but XML in memory somehow (an...
10
by: Mamuninfo | last post by:
Hello, Have any function in the DB2 database that can generate unique id for each string like oracle, mysql,sybase,sqlserver database. In mysql:- select md5(concat_ws("Row name")) from...
2
by: SalimShahzad | last post by:
Dear Gurus, i had written following codes to auto generate the next claim no Private Const strC = "GCT/02/J/" Private Sub Command1_Click() Dim stra, stre As String Dim intb, intd As Integer...
4
by: Chris Bower | last post by:
Reposted from aspnet.buildingcontrols: Ok, I've got a bunch of derived controls that all have a property Rights of type Rights (Rights is an Enumerator). I wrote a custom TypeConverter so that I...
1
by: A Traveler | last post by:
Hello, i am having this problem. The exact error message is: "Unable to generate code for a value of type 'System.Web.UI.Page'. This error occurred while trying to generate the property value for...
1
by: Alexander Kaplunov | last post by:
I have a web service, which has a reference to a class. I want to be able to accept this class as a parameter to my web service method. When the consumer consumes the web service, proxy class is...
5
by: Chameleon | last post by:
I totally messed up with this: We have -------------------------------------- generate(v.begin(), v.end(), my_func); -------------------------------------- and my_func: ----------- int...
9
by: Anubhav Jain | last post by:
Hi, I am having few .net source files(.cs or .vb) and I want to dynamically generate the corresponding .net project file(.csproj or .vbproj) for them without using visual studio.So that I could...
15
by: Ashish Khandelwal | last post by:
As MSDN is not giving us guarantee upon uniqueness of Hash Code, so could any one suggest me that how to generate a unique Hash Code for same string always, and generate different-2 Hash Code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.