Questions tagged [hash]

A hash function is any well-defined procedure or mathematical function that converts a large amount of data into a small datum, usually a single integer. For questions about hashtags as used to label content on social media, use hashtag. For questions about URLs and HTML anchors, use fragment-identifier. For questions about Ruby's hash type, use ruby-hash.

A is any well-defined procedure or mathematical function that converts a large, possibly variable-sized amount of data into a small datum, usually a single integer that may serve as an index to an array. The values returned by a hash function are called hash values, s, hash sums, checksums or simply hashes. A occurs when two unequal datums generate the same hash code with a particular hash function. This can have various negative effects and good hash functions minimize the number of collisions.

For data structures that make use of hash functions and hashcodes, see , , , , and .

A cryptographically strong hash function has two additional features: it is mathematically proven to be irreversible and minimizes collisions. Irreversibility means that the original data cannot be reconstructed from its hash. For questions specifically about cryptographically secure uses of hash functions, use combined with the tag. Contrast with , which must be reversible.

Hash functions are related to (and often confused with) checksums, check digits, fingerprints, randomization functions, and error-correcting codes. Although these concepts overlap to some extent (some hash functions are specifically designed to also serve as checksums), each has its own uses and requirements and is designed and optimized differently.

For questions about hashtags as used to label and navigate content on social media, use . For questions about URLs and HTML anchors, use . For questions about Ruby's hash type, use .

23903 questions
9
votes
2 answers

Storing hashed passwords in MySQL

I'm creating hashed passwords using salted sha1 in PHP. My question is: In MySQL what is the proper character encoding, field type & length to store the result? Is there anything else in MySQL to consider for password security? Finally are SHA256 or…
YsoL8
  • 2,186
  • 5
  • 29
  • 47
9
votes
2 answers

project.pbxproj hashing for files - what hash is used and how?

If you look into project.pbxproj, you shall see that every file in the project has a hash For example 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework…
inteist
  • 493
  • 8
  • 15
9
votes
5 answers

Should I cache the hash code of an STL string used as a hash key?

I've doing some performance analysis on the software I develop, and I've found that lookups on a global dictionary of URL's takes about 10% of the application's "load" phase time. The dictionary is implemented as a C++ STL std::map, which has O(lg…
David Gladfelter
  • 4,175
  • 2
  • 25
  • 25
9
votes
1 answer

Specializing std::hash to derived classes

I have an abstract base class Hashable that classes that can be hashed derive from. I would now like to extend std::hash to all classes that derive from Hashable. The following code is supposed to do exactly that. #include #include…
Flecto
  • 315
  • 2
  • 7
9
votes
2 answers

Shortest hash? MD5 / SHA . First chars, git

I need hash function. Users will be write these hash to computer so hash should be short. I will have about 50 000 000 records in database. Each must have own hash. I would like to have unique hashes. But if a little records have the same hash, I…
martin
  • 1,707
  • 6
  • 34
  • 62
9
votes
6 answers

Password hashing in a C# Windows app, absent ASP.NET's FormsAuthentication?

My Win form app doesn't seem to like FormsAuthentication, I'm totally new to hashing so any help to convert this would be very welcome. Thanks. //Write hash protected TextBox tbPassword; protected Literal liHashedPassword; { string…
Lisa W
9
votes
3 answers

Assigning Each User a Unique 100 character Hash in Ruby on Rails

I have a form on a website that takes in some personal information from the visitor. I'm passing this information to another service and I need to assign each one of these form submits a 100 character unique hash to be stored in the DB with the…
Splashlin
  • 7,225
  • 12
  • 46
  • 50
9
votes
4 answers

How to avoid NoMethodError for nil elements when accessing nested hashes?

If I try to access a hash element that isn't present, I get NoMethodError: undefined method '[]' for nil:NilClass. However, I can't predict which elements will be present. @param_info = {} @param_info["drug"]["name"] # => NoMethodError: undefined…
Rob
  • 7,028
  • 15
  • 63
  • 95
9
votes
1 answer

OpenSSL passwd hash not consistent

I'm trying to hash an inputted password using the OpenSSL passwd command and compare it to the stored hash, but the hash function is not consistent. The hash generated the first time around is not the same hash that is being generated when I go to…
Casey Hancock
  • 508
  • 6
  • 19
9
votes
1 answer

Probability of collision with truncated SHA-256 hash

I have a database-driven web application where the primary keys of all data rows are obfuscated as follows: SHA256(content type + primary key + secret), truncated to the first 8 characters. The content type is a simple word, e.g. "post" or "message"…
CoderMD666
  • 997
  • 1
  • 8
  • 16
9
votes
5 answers

PowerShell: Custom Property XML Tags with ConvertTo-XML Output

I am creating a new object in PowerShell, using a hash table to set property values. I want to then export the object into XML format using the ConvertTo-XML method. $hash = @{ Processor = 'Intel' Disk = '500GB' …
corneria
  • 608
  • 3
  • 11
  • 24
9
votes
2 answers

Hash integer array

I am using a hash set in which I store array of integers(32 bits). This means I need an algorithm to hash an array of integers. I am looking for a 32 bits integer(C# int) hash. I have tried and edited two existing algorithms, which you can see the…
Aart Stuurman
  • 3,188
  • 4
  • 26
  • 44
9
votes
7 answers

Is Hashing a suitable solution? Am I over-complicating it?

I write a 2D platformer game where I need rooms with (maximum 4) doors. I write it in Java, but the language is irrelevant. Each room can have 4 doors, on the top, bottom and sides. I call them NORTH, SOUTH, EAST and WEST. When I'm building a room,…
Dávid Tóth
  • 2,788
  • 1
  • 21
  • 46
9
votes
1 answer

Storing a SHA512 Password Hash in Database

In my ASP.NET web app I'm hashing my user passwords with SHA512. Despite much SO'ing and Googling I'm unclear how I should be storing them in the database (SQL2005) - the code below shows the basics of how I'm creating the hash as a string and I'm…
Chris
  • 1,324
  • 5
  • 18
  • 29
9
votes
4 answers

Turning a hash into a string of name-value pairs

If I'm turning a ruby hash into a string of name-value pairs (to be used in HTTP params, for example), is this the best way? # Define the hash fields = {"a" => "foo", "b" => "bar"} # Turn it into the name-value string http_params = fields.map{|k,v|…
jerhinesmith
  • 15,214
  • 17
  • 62
  • 89
1 2 3
99
100