Is there any simple to use hashing algorithm to generate a 48-bit hash? I need to generate unique MAC addresses from unique input strings. There are no security issues here, just a question of mapping it to MAC address space (which is 48 bits).
I thought about CRC32, which is just 32 bits and easy (and cksum
is on every Linux), and use them for the lower 32 bits, but the collisions are pretty high if it is more than a few hosts.
If I could get 48 bit hash, I could mask the second least significant bit of the 8 most significant bits to ensure it is a Locally Administered Address. The loss of a single bit is minor.
Conversely, I could use a longer hashing algorithm (MD5, SHA1, etc.) and just take the 48 most significant or least significant bits.
Is there a simple way to do this?
My preference is command-line utility, but if I have to write short python or similar, no big deal.