I'm looking at using something like Crockford Base-32 encoding in a situation where people have to manually write IDs in a very compact space. Crockford Base-32 describes a simple checksum algorithm using modulo 37 that will catch a single substitution or transposition, which helps a lot when dealing with poor handwriting, transcription errors, smudging, etc (compared to a simple incrementing ID).

What I'm curious about is how I would determine the benefit I might gain by using a larger prime number for the checksum? The 37 described requires 6 bits to store, which leaves 58 bits for unique IDs when stored as a 64-bit integer. That's way more than I could ever need. So I'm thinking about upping it to a 10-bit checksum, or two base 32 characters (and eschewing the extra characters Crockford supplies for the checksum). That gives me 1021 as a potential prime number to use.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.