What is the fastest Redundancy Checksum in C# for a string?
Question
I have a string, 20-30 characters long, contains case sensitive letters and numbers
I need to generate a 2 chars checksum (in cased sensitive letters and numbers as well)
and put them together for an unique id
What is the fastest method in C# to calculate a checksum for verification purpose?
Solution
You have three problems:
Fast checksum calculation for a string: Adler32 is fast enough with good enough distribution for it's speed.
Converting checksum into a string of your character set (case sensitive letters + numbers): If you could add
+
and/
characters, you could easily use base64Generating a unique ID from those two: This is just impossible with given method. Because you'll end up with same checksum for same string, which doesn't help uniqueness.
What you can do there is to use a global counter if your item set is limited and increment it everytime you create a new record.