Questions tagged [hash-function]

A hash function is an algorithm that maps large data sets of keys to smaller data sets of a fixed length. Hash functions are not reversible.

The values returned by a hash function are called hash values, hash codes, hash sums, checksums or simply hashes.

Hash functions are mostly used to accelerate lookup times for data comparison tasks such as finding items in a hash table, database, detecting duplicated or similar records in a large file, etc.

Read more on Wikipedia.

264 questions
0
votes
1 answer

Hashing int16_t to uint64_t

I'm trying to make a hash function for int16_t. The function prototype looks like this: uint64_t hash_int16_t(const void *key); So far I've gotten this but I don't know if this is the correct approach: uint64_t hash_int16_t(const void *key) { …
user8298902
0
votes
1 answer

Perfect hash function generator

I am writing a parser (in C++) and I have a small list of strings (less than 100) where each one represents a valid parser tag. I need to map each such known tag to an enum value for further processing. As all strings are known at compile time, I…
Pouria
  • 155
  • 3
  • 12
0
votes
0 answers

Representing relations in wordlist by adjacency list for quick search

I am writing a program that is supposed to read a file of words and then find the shortest from one word to another by going from the startword to an adjacent word that will differ with one letter, simple example: Startword: dog endword: for could…
0
votes
1 answer

Does Java hashCode method do both conversion and compression?

In other words, is the integer returned by hashCode() already an index to an entry of a hash table or does it have to go one step further by compressing itself to an index (by mod the table length maybe)?
0
votes
1 answer

what is the method to check logging hash encrypted password matches with saved hashed password in the database

I use sha512.js file and for security purpose I send my password as a hash value with post request. Now I want to check with the saves hash password in the database. When I check my browser It can be seen password as a hash value. Then in my php…
user2552863
  • 483
  • 3
  • 10
  • 18
0
votes
1 answer

Widely used hashing algorithm in Java for implementing Hash tables?

I am implementing a basic HashTable data structure in Java without using collection framework and Arrays. I intend to use individual nodes whose reference I would store in an array. I am doing it this way: Define a Node: class Node { private…
CuriousMind
  • 8,301
  • 22
  • 65
  • 134
0
votes
0 answers

Static introspection of suitable hash function depending on type of hash key

I'm looking for information regarding fast non-cryptographic hash functions designed for small keys (1-32 bytes). I'm especially interested in the context of system languages such as C++, D, Rust where different hash-function could be defaulted by…
Nordlöw
  • 11,838
  • 10
  • 52
  • 99
0
votes
1 answer

how can I verify that this hash function is not gonna give me same result for two diiferent strings?

Consider two different strings to be of same length. I am implementing robin-karp algorithm and using the hash function below: def hs(pat): l = len(pat) pathash = 0 for x in range(l): pathash += ord(pat[x])*prime**x # prime is…
0
votes
1 answer

How can I hash multiple unordered objects? (strings)

I'm looking for a way to get a hash value from a group of strings, such that no matter which order the strings, the same hash returns. One way I guess would be to sort them before hashing. But I wonder if there's something more elegant.
gerbil
  • 859
  • 7
  • 26
0
votes
0 answers

Why i'm getting this error and what is the alternative solution of this

I'm trying to create a login page in which I'm trying to use Form Authentication hash function but I'm getting this error message FormsAuthentication.HashPasswordForStoringInConfigFile(string, string) is obsolete: the recommended alternative is to…
0
votes
1 answer

Searching for a 3D vector in an array

I have a large array (>1 million) of 3-dimensional points, a 3-tuple (x, y, z) which takes float values. The points are bounded between (0,0,0) and (Nx, Ny, Nz). I am interested in finding the index of a point coming from some calculation, say R,…
Rak
  • 99
  • 1
  • 4
0
votes
0 answers

Difficulty implementing djb2 hash function

I'm trying to create a function for a hash table, but when I run my code I get a warning saying assignment makes integer from pointer without a cast. My code is: //from header file //word_t is char* typedef word_t* vc_ht_key; typedef void…
Kayanda
  • 9
  • 3
0
votes
2 answers

How to spike hash function collision rate?

Given there are billions cookies, UUID like strings, what is the best way to test collision rate of say 32 bit hash function like murmur3 on this sample? First of all it is hard to generate billions of unique strings as it is impossible to keep it…
lisak
  • 21,611
  • 40
  • 152
  • 243
0
votes
0 answers

Reducing the hash value of SHA 256 using modulus

I am trying to create an alternative to a bloom filter. I am using an array of bits that has capacity to hold 100 billion bits (around 25 GB). Initially, all the bits will be set to zero.The steps I will take to create it are as follows : I will…
Aniketh Jain
  • 603
  • 7
  • 25
0
votes
1 answer

How to implement the hash function for the various type of key?

I have implemented the hash map in C++. Everything works fine, except the hash function. I have a template class of the element so that I can use various variable types for the hash map. Here is my code for the element. template
Uni
  • 3
  • 4