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

Hash Functions and storage in hash table

I am studying programming and in the school book it states that given key x, hashtable A[] and hash function h() the key x it is stored in A[h(x)-1] position (with C++ implementation). However, using as hash function the function h(x)=xmodM, where…
gdaras
  • 9,401
  • 2
  • 23
  • 39
0
votes
1 answer

For a given hash value, is it possible to guess whether it is generated by MD5 or SHA-1?

Given a hash value, is it possible to guess the hash function used to generate it? For example, let's say that 9b35a8503abcecadfb85726cfefb99a9 is generated by MD5 or SHA-1(If it's SHA-1, let's say that it is only the first 16 bytes of it), and the…
Beck
  • 1
0
votes
1 answer

Bijective hash function

The function that returns the hash can return the same index for different id values: hash(id) = id%ARRAY_SIZE Is there a way to have the hash function being bijective. I thought of: hash(id) = id But I do not have contiguous id values. Does…
Bionix1441
  • 2,135
  • 1
  • 30
  • 65
0
votes
4 answers

Mapping Unique 16-Digit numeric ID to Unique Alphanumeric ID

In a project I'm working on, I need to generate 16 character long unique IDs, consisting of 10 numbers plus 26 uppercase letters (only uppercase). They must be guaranteed to be universally unique, with zero chance of a repeat ever. The IDs are not…
watermelon82
  • 11
  • 1
  • 4
0
votes
0 answers

In Java, how would I implement a hash function that takes a string array as an argument and returns an index value for that string?

I'm supposed to create a hash table that applies a hash function to a first and last name (key) and lookup the appropriate index. The telephone number (value) should be returned on doing a lookup. Although I'm really asking for help with my hash…
user7912
  • 1
  • 2
0
votes
1 answer

Is SHA1 and SHA256 associative?

Let x be a variable over which we intend to use the hash function. I want to know if SHA256(SHA1(x)) is equal to SHA1(SHA256(x))?
mitbos
  • 27
  • 4
0
votes
2 answers

folding hash function in clojure

A folding hash function breaks its input (int, in this case) to segments of p length and adds those parts. If (not (= (mod input p) 0 )), that is, the input's length is not a multiple of p, the last segment may be of an arbitrary length less than…
David Shaked
  • 3,171
  • 3
  • 20
  • 31
0
votes
1 answer

Randomness of a hash function

I have read that randomness and uniform distribution are quite important for a hash function. How do I make a comparison between the randomness property of two different hash functions?
Kishan Kishore
  • 451
  • 6
  • 12
0
votes
1 answer

rehashing function in C

I'm doing a hash table and have implemented the following hash function int linesn=8; int hash(char *str, int table_size) { int sum; // Make sure a valid string passed in if (str==NULL) return -1; // Sum up all the characters in the string for( ;…
0
votes
1 answer

Laravel 5 login issues with second hash function

I added a hash function to registrar in Laravel 5 using the php hash function: $password = $data['password']; $salt = uniqid(mt_rand(), true); $saltpass = $password.$salt; $hashed = hash('sha256', $saltpass, false); $b_hashed =…
0
votes
1 answer

Trouble creating custom hash function unordered_map?

I wanted to create a custom hash function for an unordered map. I found this question: C++ unordered_map fail when used with a vector as key and found that if you use a vector as a key in an unordered map, you need to create your own hash function.…
user1871869
  • 3,317
  • 13
  • 56
  • 106
0
votes
0 answers

Finding a hash function that has specific properties

My question relates a lot to this topic: Hash function on list independant of order of items in it Basically, I have a set of N numbers. N is fixed and is typically quite large, eg. 1000 for instance. These numbers can be integers or floating-point.…
Martin Frank
  • 199
  • 1
  • 13
0
votes
1 answer

Does a linear cryptographic hash function exist?

Does a linear cryptographic hash function exist? By linear I mean a function 'f' such that: where + is mod n for some large constant n
0
votes
3 answers

Quickest way of storing and accessing Strings in an array

I know I could go through a for loop like this (see code) and i could also add to the array in the same fashion but is there a quicker way. I don't want to use any other java API as i want to practice array's. Would using a hash function allow me to…
Kingsta1993
  • 25
  • 1
  • 1
  • 5
0
votes
0 answers

Template Hash-Function for string and integers

I am creating a HashTable class via a template. Although, I can't seem to find a way to keep the template nature when dealing with strings or any numerical datatype (more-so just integers). This is the code that I have that works as long as HashKey…
Andrew B
  • 9
  • 1
  • 1
  • 2