![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
In using the following syntax for a web page to demonstrate MD5 using VB, I noticed that the output is not the same as the md5 output you get from the command line in linux. Any tips on how I can get them to match up? Example md5 -dpassword yields: 5F4DCC3B5AA765D61D8327DEB882CF99 when I enter "password" on the following form I get: sIHb6F4ew//D1OfQInQAzQ Perhaps it has something to do with the base 64 conversion below? %@ Import Namespace="System"% %@ Import Namespace="System.Text"% %@ Import Namespace="System.Security.Cryptography" % script runat="server" language="VB" Sub Page_Load(sender as Object, e as EventArgs) If IsPostBack Then Dim HashValue as Byte() Dim UE As New UnicodeEncoding() Dim MessageBytes As Byte() = UE.GetBytes(txtStuff.Text) Dim Md5 As New MD5CryptoServiceProvider() HashValue = MD5.ComputeHash(MessageBytes) Dim theValue = Convert.ToBase64String(HashValue) Response.Write(theValue.Replace("==","")) End If End Sub /script form runat="server" h1>Enter text to be hashed:</h1 br asp:TextBox runat="server" id="txtStuff" / p><asp:Button runat="server" Text="Encrypt Text" /></p /form ___ Newsgroups brought to you courtesy of www.dotnetjohn.com |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |