Jump to content



Photo

Hash Codes


  • Please log in to reply
7 replies to this topic

#1 Dark Prince

Dark Prince

    Advanced Member

  • Members
  • PipPipPip
  • 62 posts
  • LocationToronto

Posted 24 January 2012 - 5:46 PM

there are so many generators for hash codes whats the best one to generate low character hashes around 6 to 12 characters?
  • 0

#2 Antonio Conte

Antonio Conte

    Advanced Member

  • Members
  • PipPipPip
  • 1,055 posts
  • LocationOslo, Norway

Posted 27 January 2012 - 4:28 AM

What are you going to use the hash codes for? Passwords? Searching for objects? You kind of have to specify the context you want to use them in.
  • 0

#3 Antonio Conte

Antonio Conte

    Advanced Member

  • Members
  • PipPipPip
  • 1,055 posts
  • LocationOslo, Norway

Posted 2 February 2012 - 3:31 PM

If you come from anorher language, like java, associative arrays works exactly as hash tables. Always an O(1) operation! :)
  • 1

#4 Dark Prince

Dark Prince

    Advanced Member

  • Members
  • PipPipPip
  • 62 posts
  • LocationToronto

Posted 12 February 2012 - 1:56 PM

I just want to create a short 8 to 12 character hash code that I can use to identify certain rows in a table instead of using an id number, and also to be used in a security check.
  • 0

#5 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,803 posts
  • LocationState College, PA (USA)

Posted 12 February 2012 - 9:05 PM

Just so you're aware, an id number will be more efficient, as databases deal with numbers faster than strings and primary keys are often used as the basis of queries.
  • 0

#6 Dark Prince

Dark Prince

    Advanced Member

  • Members
  • PipPipPip
  • 62 posts
  • LocationToronto

Posted 15 February 2012 - 3:59 PM

I'm not sure I want to use it for identify rows in a table yet but it would be nice to be able to add a 8 character hash to some fields like file uploads having a hash before the file name will reduce the likeliness of a file being overwritten by 99.999%, does cr32 create an 8 character hash or does it need to be truncated?
  • 0

#7 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,803 posts
  • LocationState College, PA (USA)

Posted 15 February 2012 - 4:53 PM

Or you could store the file name using the primary key for the related table, which would 100% guarantee no overwrites.

As for "cr32", there's no such thing. If you're asking about crc32(), check out the PHP manual to see what it returns, or try it in code yourself.
  • 0

#8 Dark Prince

Dark Prince

    Advanced Member

  • Members
  • PipPipPip
  • 62 posts
  • LocationToronto

Posted 16 February 2012 - 3:12 PM

well in some of my tables there is more then 1 file upload per row, but yeah it was crc32 and yeah you are right I should just check it myself to see what I get.
  • 0