I have tried UUID and its generating 32 character string.But I want 16 character unique string
Since a UUID is 128 bits, 128 / 16 = 8, you need to cram 8 bits into each character. So you could express the UUID as a char[16] -- but it would not be printable as a string.
ASCII only uses 7 bits, and many of those are non-printable.
You could possibly express an 8 bit number as a String of length 1 by identifying 256 printable unicode codepoints (for example, dingbats, chinese characters etc.) and mapping these to values. This would allow you to display a UUID in an 8-character-wide space on unicode-capable displays. You would probably be able to copy-and-paste these, but care would be needed moving them around - manually typing them would be challenging.
It needs to have 32 characters to be unique.
Lazy way: only tke the first 16 chars (might not always work)
Proper way: find a formula which can break down a 32 character UUID to a 16 character UUID.
Different way: Use the hashcode instead (only works when needing UUID's once)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With