I have a unique ID number with 2^128 magnitude length (128 bits). This means ~3.4e+38 which is quite large that my actually needs, spending valuable time in a transmission protocol.

There is a algorithm that will keep only 2^32 and still guarantees that result is unique?

  • 4
    $\begingroup$ Strictly speaking: No. But if you know that these IDs have a certain redundant structure (which is quite likely with this high number of possiblities) or are stored in an inefficient way you can try to compress it with the Compress command. $\endgroup$ – Henrik Schumacher Jul 4 '17 at 10:56
  • $\begingroup$ If you are generating these unique ID's yourself there are ways to generate shorter hash codes; check the documentation for Hash[] $\endgroup$ – Daniel W Oct 27 '17 at 13:49
  • $\begingroup$ @DanielW not all hashes offered by Hash are intended to be unique signatures of the input. Generally, only the cryptographic ones are. The others are for applications such as making hash tables, where one only requires a uniform distribution of hash codes among the possible inputs; or for error checking, where one only requires that the hash values for similar inputs differ with very high probability. So, short hashes are not alternatives to the long ones, in any general sense. $\endgroup$ – Oleksandr R. Oct 27 '17 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.