S
S
Snewer2017-10-17 22:56:26
Algorithms
Snewer, 2017-10-17 22:56:26

How to get the numeric hash of a string in a given range?

Hello!
We need an algorithm to get the hash of a string.
The hash must be an integer between 0 and n. Where n is set manually.
For example, n = 5.
myhash('test1') = 1
myhash("qwerty") = 5
myhash('hello, world!') = 5
myhash("132") = 0
Thanks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andryukha, 2017-10-17
@Snewer

take one of the standard algorithms, then divide its result without a remainder
https://barrgroup.com/Embedded-Systems/How-To/CRC-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question