how do i encrypt/hash a text with the easiest or simplest form of
encryption in less than 3-4 lines given i have txtField.Text = "George King"
to become a 32 character word regardless of input size.
Printable View
how do i encrypt/hash a text with the easiest or simplest form of
encryption in less than 3-4 lines given i have txtField.Text = "George King"
to become a 32 character word regardless of input size.
Off the top of my head. Probably not optimal for speed but it should be fairly secure.
VB Code:
Public Function Get32ByteHash(ByVal data As String) As String Dim temp As String = data.GetHashCode.ToString("X").PadLeft(8, "0"c) For i As Integer = 0 To 2 'compound hashing temp &= temp.GetHashCode.ToString("X").PadLeft(8, "0"c) Next i Return temp End Function
Note: Revised the code.
On second thoughts, this will be just as good...
VB Code:
Public Function Get32ByteHash(ByVal data As String) As String Return data.GetHashCode.ToString("X").PadLeft(32, "0"c) End Function
There would be no benefit from that loop in the earlier posted code, since there would be a 1:1 relationship between the first hash and the 4th one. May as well just pad it with zeroes.
thanks, i'm using dreamweaver's asp.net vb INSERT record, how do i encrypt the password the user type into the textbox
<input name="password" type="password" id="password" size="20" maxlength="15" runat="server">
<MM:Insert
runat="server"
CommandText='<%# "INSERT INTO Particulars (active, address, city, company, country, created, dob, email, fax, firstname, gender, hometelephone, lastname, mobile, officephone, password, security, state, zip) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_connSoftwares") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_connSoftwares") %>'
Expression='<%# Request.Form("MM_insert") = "Registration" %>'
CreateDataSet="false"
SuccessURL='<%# "completed.aspx" %>'
FailureURL='<%# "failed.aspx" %>'
><Parameters>
<Parameter Name="@active" Value='<%# IIf((Request.Form("active") <> Nothing), Request.Form("active"), "") %>' Type="Boolean" />
<Parameter Name="@address" Value='<%# IIf((Request.Form("address") <> Nothing), Request.Form("address"), "") %>' Type="WChar" />
<Parameter Name="@city" Value='<%# IIf((Request.Form("city") <> Nothing), Request.Form("city"), "") %>' Type="WChar" />
<Parameter Name="@company" Value='<%# IIf((Request.Form("company") <> Nothing), Request.Form("company"), "") %>' Type="WChar" />
<Parameter Name="@country" Value='<%# IIf((Request.Form("country") <> Nothing), Request.Form("country"), "") %>' Type="WChar" />
<Parameter Name="@created" Value='<%# IIf((Request.Form("created") <> Nothing), Request.Form("created"), "") %>' Type="Date" />
<Parameter Name="@dob" Value='<%# IIf((Request.Form("dob") <> Nothing), Request.Form("dob"), "") %>' Type="Date" />
<Parameter Name="@email" Value='<%# IIf((Request.Form("email") <> Nothing), Request.Form("email"), "") %>' Type="WChar" />
<Parameter Name="@fax" Value='<%# IIf((Request.Form("fax") <> Nothing), Request.Form("fax"), "") %>' Type="Numeric" />
<Parameter Name="@firstname" Value='<%# IIf((Request.Form("firstname") <> Nothing), Request.Form("firstname"), "") %>' Type="WChar" />
<Parameter Name="@gender" Value='<%# IIf((Request.Form("gender") <> Nothing), Request.Form("gender"), "") %>' Type="WChar" />
<Parameter Name="@hometelephone" Value='<%# IIf((Request.Form("hometelephone") <> Nothing), Request.Form("hometelephone"), "") %>' Type="Numeric" />
<Parameter Name="@lastname" Value='<%# IIf((Request.Form("lastname") <> Nothing), Request.Form("lastname"), "") %>' Type="WChar" />
<Parameter Name="@mobile" Value='<%# IIf((Request.Form("mobile") <> Nothing), Request.Form("mobile"), "") %>' Type="Numeric" />
<Parameter Name="@officephone" Value='<%# IIf((Request.Form("officephone") <> Nothing), Request.Form("officephone"), "") %>' Type="Numeric" />
<Parameter Name="@password" Value='<%# IIf((Request.Form("password") <> Nothing), Request.Form("password"), "") %>' Type="WChar" />
<Parameter Name="@security" Value='<%# IIf((Request.Form("security") <> Nothing), Request.Form("security"), "") %>' Type="Numeric" />
<Parameter Name="@state" Value='<%# IIf((Request.Form("state") <> Nothing), Request.Form("state"), "") %>' Type="WChar" />
<Parameter Name="@zip" Value='<%# IIf((Request.Form("zip") <> Nothing), Request.Form("zip"), "") %>' Type="Numeric" />
</Parameters>
</MM:Insert>
<MM:PageBind runat="server" PostBackBind="true" />
anyone?
help appreciated!