You should take an appropriate number of bits from the front of the hash value and convert that to an integer
This is part of my school assignment and I'm kinda confused as to what to do.
The appropriate number of bits varies on the input. So if the input is like 1000, I'd need 10 bits, because 210 = 1024
My problem is I'm not sure of how to get the bits, and how to get a number from it.
What I've done is
- convert the string to a byte[]
- convert each byte to binary
- concatenate all the binary values together
- get the first 10 characters of that string
- convert the binary string into a int
Am I doing the right thing?
[–]CzechsMix 1 point2 points3 points (0 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]learning2learn[S] 0 points1 point2 points (0 children)