This is a method that allows calculate a prime number using a hash. The idea is really simple: we generate a number n passing the hash from 16-basis to a special basis, taken the value of tha char in 10-basis and multiply by 2i, where i is the position of the char in the string. This number n, we calculate the rest module 31, obtaining an other number d. We find the numbers x=2d-1 and y=2^(d+1)-1. We call a function that returns the first prime nuber in [x,y]. This will be our choice.
We apply module 31 for 2 reasons:
- Every prime generate will be lower than 2^32.
- We can work with up 2512. If every prime is lower than 232, we can use 16 or more hashes.
Exemples of output
ba0eb08fb6e22be90efdddbcc4e01e6b
14
PRIME:16411
59d979a35b796a359ca93b5551543989
10
PRIME:1031
c1db9ac31e24338f84d6478cd240c469
10
PRIME:1031
8cc7f325e1f85c4495ed1d5dd9241322
20
PRIME:1048583
ccf5c961e56ea0f5ed9fd2ad708bb222
12
PRIME:4099
e321b05a921a43e28a047c8d3f3badfe
0
PRIME:2147483647
f64db73f55c13d867ff371bdff1cd535
14
PRIME:16411
41f0d73e282a545a986a32c435307141
10
PRIME:1031
61aead180d629200cc69792ca8152415
14
PRIME:16411
e93f049d72d96884c3d35dda9b9c5f3f
18
PRIME:262147
c44f76fcb1a959281f4abe02cb1b1352
0
PRIME:2147483647
c44f76fcb1a959281f4abe02cb1b1352
0
PRIME:2147483647
907faf1c31f729fd2fdb6e66d2b300f2
0
PRIME:2147483647
116071665641408661462957134870906380377375371356177661370878538945945071899
This is the product of all primes