How to shorten a 64-bit hash value down to a 48-bit value?

前端 未结 3 651
日久生厌
日久生厌 2020-12-09 07:03

I already have a 64 bit hash function in a library (C coding), but I only need 48 bits. I need to trim down the 64 bit hash value to a 48 bit value, yet it has to be in a sa

3条回答
  •  一个人的身影
    2020-12-09 07:45

    There exist no 48-bit hash algorithms as far as I know. Neither do 48-bit variable types exist, so this is a very strange design choice anyway.

    And of course you can't shorten a 64-bit hash down to a 48-bit without loss and safe hashing is a completely different topic anyway. You could do something like using a common 32-bit hash function like CRC32 or so and just have 16 empty bits. Or even combining a 32-bit and 16-bit but that seems really really odd. From a collision-safe standpoint this isn't even a thing and I wouldn't want to hear the response of a cryptologically experienced person on this.

    My recommendation: Use standard sized established hashing algorithms and don't make experiments. It's already hard enough to come up with a good hashing algorithm anyways. There's no need to become creative except you're an expert on your field and can handle the effects the change may have (which is probably the most difficult part).

提交回复
热议问题