3 Byte output hashing algorithm

656 Views Asked by At

So for a project that I am working on, I am trying to get a hashing algorithm but I don't know anything about hashing algorithms. The final outcome I would like to archive is inputing a 6 byte value and get 3 unique bytes as my output.

My other alternative is one algorithm that inputs a 2 byte value and outputs 1 unique byte.

Is this possible?

** Edit: I would need this in C language if possible or pseudo code.

1

There are 1 best solutions below

2
hangonstack On

Most hash functions can take arbitrary numbers of bytes since they are by nature compression functions. As for the output, you can just take the first 3 bytes of the output. Any cryptographically safe hash function will output bytes that are suitable for this.

For example, in Python it would be:

from hashlib import sha256

s = sha256(<your bytes>)
output = s.digest()[:3]