Simple string hashing

Discussion in 'ASP General' started by Seth, Jun 26, 2004.

  1. Seth

    Seth Guest

    I want to create a simple hash function that can hash strings. Currently I'm
    storing passwords as strings in a DB but want to store them as a hash. I
    don't need any proper standardised hashing e.g. MD4 or MD5. I also want to
    be able to write the function completely using VB Script (therefore no
    components etc)

    I'm thinking along the lines of converting the string into a number
    (probably using the ascii values in some simple formula)
    Then divide this by a really large prime number (as large as can fit in a VB
    Script variable)
    And use the remainder as the hash

    This is probably very crude but sufficient for my website. Can anyone give
    me any tips on the easiest way to do the above or if it can be improved with
    very little extra effort.
    Also, what is the largest number that can be stored in a VB script variable,
    is it a signed 32 bit number?
    And the last question is, how can I find out what the largest prime number
    is less than that number? Obviously, I don't need to use a prime number but
    it would be better if I did. Thanks in advance
     
    Seth, Jun 26, 2004
    #1
    1. Advertising

  2. Seth

    Chris Barber Guest

    Google:
    http://p2p.wrox.com/archive/proasp_howto/2002-02/27.asp

    Chris.

    "Seth" <> wrote in message news:rvgDc.96$MI2.70@newsfe6-win...
    I want to create a simple hash function that can hash strings. Currently I'm
    storing passwords as strings in a DB but want to store them as a hash. I
    don't need any proper standardised hashing e.g. MD4 or MD5. I also want to
    be able to write the function completely using VB Script (therefore no
    components etc)

    I'm thinking along the lines of converting the string into a number
    (probably using the ascii values in some simple formula)
    Then divide this by a really large prime number (as large as can fit in a VB
    Script variable)
    And use the remainder as the hash

    This is probably very crude but sufficient for my website. Can anyone give
    me any tips on the easiest way to do the above or if it can be improved with
    very little extra effort.
    Also, what is the largest number that can be stored in a VB script variable,
    is it a signed 32 bit number?
    And the last question is, how can I find out what the largest prime number
    is less than that number? Obviously, I don't need to use a prime number but
    it would be better if I did. Thanks in advance




    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.710 / Virus Database: 466 - Release Date: 23/06/2004
     
    Chris Barber, Jun 26, 2004
    #2
    1. Advertising

  3. Seth

    Seth Guest

    Thanks for that, works a treat and saved me some time :)

    "Chris Barber" <> wrote in message
    news:...
    > Google:
    > http://p2p.wrox.com/archive/proasp_howto/2002-02/27.asp
    >
    > Chris.
    >
    > "Seth" <> wrote in message

    news:rvgDc.96$MI2.70@newsfe6-win...
    > I want to create a simple hash function that can hash strings. Currently

    I'm
    > storing passwords as strings in a DB but want to store them as a hash. I
    > don't need any proper standardised hashing e.g. MD4 or MD5. I also want to
    > be able to write the function completely using VB Script (therefore no
    > components etc)
    >
    > I'm thinking along the lines of converting the string into a number
    > (probably using the ascii values in some simple formula)
    > Then divide this by a really large prime number (as large as can fit in a

    VB
    > Script variable)
    > And use the remainder as the hash
    >
    > This is probably very crude but sufficient for my website. Can anyone give
    > me any tips on the easiest way to do the above or if it can be improved

    with
    > very little extra effort.
    > Also, what is the largest number that can be stored in a VB script

    variable,
    > is it a signed 32 bit number?
    > And the last question is, how can I find out what the largest prime number
    > is less than that number? Obviously, I don't need to use a prime number

    but
    > it would be better if I did. Thanks in advance
    >
    >
    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system (http://www.grisoft.com).
    > Version: 6.0.710 / Virus Database: 466 - Release Date: 23/06/2004
    >
    >
     
    Seth, Jun 26, 2004
    #3
  4. Seth

    Eric Gibson Guest

    Seth wrote:
    > I want to create a simple hash function that can hash strings.
    > Currently I'm storing passwords as strings in a DB but want to store
    > them as a hash. I don't need any proper standardised hashing e.g. MD4
    > or MD5. I also want to be able to write the function completely using
    > VB Script (therefore no components etc)
    >


    Here is a function in VBScript to hash strings in classical ASP:

    http://rossm.net/Electronics/Computers/Software/ASP/#MD5

    It's fast and efficient from my experience.

    In ASP.NET just use the System.Cryptography namespace. There are MD5
    functions in it.



    > I'm thinking along the lines of converting the string into a number
    > (probably using the ascii values in some simple formula)
    > Then divide this by a really large prime number (as large as can fit
    > in a VB Script variable) And use the remainder as the hash
    >
    > This is probably very crude but sufficient for my website. Can anyone
    > give me any tips on the easiest way to do the above or if it can be
    > improved with very little extra effort. Also, what is the largest
    > number that can be stored in a VB script variable, is it a signed 32
    > bit number? And the last question is, how can I find out what the
    > largest prime number is less than that number?



    If I knew how to quickly calculate high primes for a 32 bit number... I
    wouldn't be telling YOU! I'd be implementing cracks for all the major
    algorithms known, and becoming the most (in)famous cryptographer in
    history...

    :)

    Eric
     
    Eric Gibson, Jun 27, 2004
    #4
  5. Seth

    Seth Guest

    Thanks for this link, However, I've already implemented the solution Chris
    pointed out. It isn't that slow and does the job for me fine.

    I also wrote a simple program that would calculate prime numbers. It takes a
    number and tells you whether it is prime or not. It also has the option of
    if it isn't a prime then it will find the next highest or next lowest prime
    number. Knowing the highest prime number for a 32 bit number doesn't let you
    crack a one way function any quicker though.

    "Eric Gibson" <> wrote in message
    news:11GDc.652$...
    > Seth wrote:
    > > I want to create a simple hash function that can hash strings.
    > > Currently I'm storing passwords as strings in a DB but want to store
    > > them as a hash. I don't need any proper standardised hashing e.g. MD4
    > > or MD5. I also want to be able to write the function completely using
    > > VB Script (therefore no components etc)
    > >

    >
    > Here is a function in VBScript to hash strings in classical ASP:
    >
    > http://rossm.net/Electronics/Computers/Software/ASP/#MD5
    >
    > It's fast and efficient from my experience.
    >
    > In ASP.NET just use the System.Cryptography namespace. There are MD5
    > functions in it.
    >
    >
    >
    > > I'm thinking along the lines of converting the string into a number
    > > (probably using the ascii values in some simple formula)
    > > Then divide this by a really large prime number (as large as can fit
    > > in a VB Script variable) And use the remainder as the hash
    > >
    > > This is probably very crude but sufficient for my website. Can anyone
    > > give me any tips on the easiest way to do the above or if it can be
    > > improved with very little extra effort. Also, what is the largest
    > > number that can be stored in a VB script variable, is it a signed 32
    > > bit number? And the last question is, how can I find out what the
    > > largest prime number is less than that number?

    >
    >
    > If I knew how to quickly calculate high primes for a 32 bit number... I
    > wouldn't be telling YOU! I'd be implementing cracks for all the major
    > algorithms known, and becoming the most (in)famous cryptographer in
    > history...
    >
    > :)
    >
    > Eric
    >
    >
     
    Seth, Jun 28, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guadala Harry
    Replies:
    4
    Views:
    383
    Steve C. Orr [MVP, MCSD]
    Sep 12, 2004
  2. =?Utf-8?B?QnJpYW4=?=

    Password Hashing and User Authentication

    =?Utf-8?B?QnJpYW4=?=, Jun 6, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    385
    =?Utf-8?B?QnJpYW4=?=
    Jun 6, 2005
  3. Sebastian Karlsson
    Replies:
    4
    Views:
    368
    Sebastian Karlsson
    Feb 13, 2008
  4. Phrogz

    String Hashing Algorithms

    Phrogz, May 10, 2005, in forum: Ruby
    Replies:
    15
    Views:
    336
    Clifford Heath
    May 12, 2005
  5. Replies:
    2
    Views:
    92
Loading...

Share This Page