Zachary Denny
Zachary Denny

Reputation: 1

3 Byte output hashing algorithm

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.

Upvotes: -3

Views: 885

Answers (1)

hangonstack
hangonstack

Reputation: 187

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]

Upvotes: 0

Related Questions