Results 1 to 7 of 7

Thread: Encryption or Hashing of text

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    106

    Encryption or Hashing of text

    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.

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Encryption or Hashing of text

    Off the top of my head. Probably not optimal for speed but it should be fairly secure.

    VB Code:
    1. Public Function Get32ByteHash(ByVal data As String) As String
    2.  
    3.         Dim temp As String = data.GetHashCode.ToString("X").PadLeft(8, "0"c)
    4.  
    5.         For i As Integer = 0 To 2      'compound hashing
    6.             temp &= temp.GetHashCode.ToString("X").PadLeft(8, "0"c)
    7.         Next i
    8.  
    9.         Return temp
    10.  
    11.     End Function
    Last edited by wossname; May 12th, 2005 at 04:20 AM.
    I don't live here any more.

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Encryption or Hashing of text

    Note: Revised the code.
    I don't live here any more.

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Encryption or Hashing of text

    On second thoughts, this will be just as good...

    VB Code:
    1. Public Function Get32ByteHash(ByVal data As String) As String
    2.  
    3.     Return data.GetHashCode.ToString("X").PadLeft(32, "0"c)
    4.  
    5. 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.
    I don't live here any more.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    106

    Re: Encryption or Hashing of text

    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" />

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    106

    Re: Encryption or Hashing of text

    anyone?

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    106

    Re: Encryption or Hashing of text

    help appreciated!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width