MD5 Algorithm in VB.NET
|
Original Message
|
Name: DarkPhoenix
Date: January 4, 2004 at 20:08:31 Pacific
Subject: MD5 Algorithm in VB.NET OS: WIN XP Pro CPU/Ram: P4
|
Comment: I am writing a program in VB.NET that needs to encrypt some text using MD5 that will be going into a file. Are there any snippets of code that can do this or something that I can use?
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: StuartS
Date: January 4, 2004 at 21:25:39 Pacific
Subject: MD5 Algorithm in VB.NET |
Reply: (edit)You can try this site. There is an Active X DLL that works very well with VB6. Should work just as well with VB.NET http://userpages.umbc.edu/~mabzug1/cs/md5/md5.html Stuart
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Sord
Date: January 5, 2004 at 15:32:21 Pacific
Subject: MD5 Algorithm in VB.NET |
Reply: (edit)this site uses the built in md5 algorithms http://www.flowgroup.fr/tech_md5_us.htm note its written in C# but should be extremely easy to port because c# and vb.net both use the same functions, just different syntax
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: jmetcalf
Date: January 15, 2004 at 10:51:19 Pacific
Subject: MD5 Algorithm in VB.NET
|
Reply: (edit)This should to the trick: Public Function MD5(ByVal number As String) As String 'Create an encoding object to ensure the encoding standard for the source text Dim ASCIIenc As New ASCIIEncoding Dim strReturn 'Retrieve a byte array based on the source text Dim ByteSourceText() As Byte = ASCIIenc.GetBytes(number) 'Instantiate an MD5 Provider object Dim Md5Hash As New MD5CryptoServiceProvider 'Compute the hash value from the source Dim ByteHash() As Byte = Md5Hash.ComputeHash(ByteSourceText) 'Cycle through the hash and convert to string For Each b As Byte In ByteHash 'Convert byte(s) to string strReturn &= b.ToString("x2") Next 'Return the result Return strReturn End Function Just call MD5("12345") from within your code.
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: