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
8 answers

SHA256 webhook signature from WooCommerce never verifies

I am receiving webhooks from a woocommerce site into a nodejs/express application. I am trying to verify the webhook's signature to prove authenticity, yet the hash I compute never corresponds to the signature that woocommerce reports in the hook's…
Luis Delgado
  • 3,644
  • 4
  • 34
  • 54
9
votes
3 answers

Shift js string one character

In PHP, it's pretty simple, I'd assume, array_shift($string)? If not, I'm sure there's some equally simple solution :) However, is there any way to achieve the same thing in JavaScript? My specific example is the pulling of window.location.hash from…
Julian H. Lam
  • 25,501
  • 13
  • 46
  • 73
9
votes
5 answers

PHP function to create 8 chars long hash ([a-z] = no numbers allowed)

I need PHP function that will create 8 chars long [a-z] hash from any input string. So e.g. when I'll submit "Stack Overflow" it will return e.g. "gdqreaxc" (8 chars [a-z] no numbers allowed)
chubbyk
  • 6,212
  • 13
  • 53
  • 67
9
votes
1 answer

Is there a way to utilize Bcrypt for iOS development with Swift?

I have been searching for a library, cocoapod, or something else that allows me to implement Bcrypt in iOS using Swift.
Bourne
  • 2,518
  • 1
  • 20
  • 27
9
votes
4 answers

Laravel - How do you use Hash::needsRehash()?

I'm wondering how to use Hash::needsRehash() as I'm struggling to see using the documentation exactly what it's for. if (Hash::needsRehash($hashed)) { $hashed = Hash::make('plain-text'); } What exactly causes Hash::needsRehash() to return true…
Jean-Luc Tallis
  • 315
  • 1
  • 4
  • 11
9
votes
1 answer

Sorting an Array Reference to Hashes

After executing these lines in Perl: my $data = `curl '$url'`; my $pets = XMLin($data)->(pets); I have an array reference that contains references to hashes: $VAR1 = [ { 'title' => 'cat', 'count' => '210' }, { …
syker
  • 10,912
  • 16
  • 56
  • 68
9
votes
1 answer

MD5 hash of blob uploaded on Azure doesnt match with same file on local machine

I am currently working on uploading media on Azure Blob storage. All is working fine except when i try to macth the MD5 hash of uploaded media with the local file (exactly same one which was uploaded). Local file returns a byte array where are…
Salman
  • 3,137
  • 4
  • 23
  • 31
9
votes
1 answer

Hash value for a std::unordered_map

According to the standard there's no support for containers (let alone unordered ones) in the std::hash class. So I wonder how to implement that. What I have is: std::unordered_map _properties; std::wstring _class; I…
Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
9
votes
6 answers

Mysql – Detecting changes in data with a hash function over a part of table

I need generate a single hash over some data in a table CREATE TABLE Table1 ( F1 INT UNSIGNED NOT NULL AUTO_INCREMENT, F2 INT default NULL, F3 Varchar(50) default …
Charles Faiga
  • 11,665
  • 25
  • 102
  • 139
9
votes
4 answers

How can I change the case of a hash key?

I am writing a script which is likely to be modified by users. Currently I am storing the configuration settings inside the script. It exists in the form of a hash-of-hashes. I would like to guard against people accidentally using lowercase…
mseery
  • 1,404
  • 2
  • 16
  • 26
9
votes
7 answers

Double hashing passwords - client & server

Hey, first, let me say, I'm not asking about things like md5(md5(..., there are already topics about it. My question is this: We allow our clients to store their passwords locally. Naturally, we don't want them stored in plan text, so we hmac them…
J. Stoever
  • 856
  • 12
  • 20
9
votes
6 answers

Hashing and salting values

I am developing a small web app that internally authenticates users. Once the user is authenticated my web app then passes some information such as userID and Person's name to a third party web application. The third party developer is suggesting…
Avanst
  • 2,115
  • 5
  • 20
  • 20
9
votes
3 answers

why is hash output fixed in length?

Hash functions always produce a fixed length output regardless of the input (i.e. MD5 >> 128 bits, SHA-256 >> 256 bits), but why? I know that it is how the designer designed them to be, but why they designed the output to have the same length? So…
Alvida
  • 145
  • 1
  • 1
  • 9
9
votes
2 answers

Convert base64'd SHA1 hashes to Hex hashes

I have a list of passwords in mySQL that are generated using $hash = '{SHA}' . base64_encode(sha1('some string here', true)); I need to convert these into what would be the equivalent of $hash = sha1('some string here'); As these are password…
Mez
  • 24,430
  • 14
  • 71
  • 93
9
votes
1 answer

How to std::hash an unordered std::pair

I want to be able to use a std::pair as a key in an unordered_container. I know that I could do this the following way: template void hash_combine(std::size_t &seed, T const &key) { std::hash hasher; seed ^= hasher(key) +…
101010
  • 41,839
  • 11
  • 94
  • 168