1

Possible Duplicate:
Example of UUID generation in c++

I need an algorithm for generating a 24 character UUID, but all I have been able to find is generators that produce the standard 32 character ones, like this:

550e8400-e29b-41d4-a716-446655440000

How can I generate a 24 character UUID?

Community
  • 1
  • 1
CuriousGeorge
  • 7,120
  • 6
  • 42
  • 74
  • Uuid is actually 16 bytes. It's string representation is 32 character long because of hex encoding. Decode it back to bytes. And encode with base64. Now you get 24 character long uuid. If you remove two redundant trailing '=' you get 22 characters while still keeping uniqueness. – Fantastory Dec 21 '18 at 13:28

1 Answers1

8

UUIDs are 32 characters (128 bits) by definition. If it's only 24 characters long, it's something else, and there's no standard for how to generate it.

  • I am trying to modify an xcode project, and each entry in the project has a unique 24 character hex number as the key to a key-value pair. Do you have any idea what that number may represent? or how I could generate one? I am assuming they are just UUID of some kind, because the same Framework is listed in two different projects with a totally different 24 char number. – CuriousGeorge Dec 15 '12 at 21:51
  • I'm not sure what they are -- the format isn't documented, so you're pretty much on your own. Have you tried just generating a random number and putting it in there? –  Dec 15 '12 at 21:56
  • I would really like to avoid that if possible. I could check my own project for uniqueness, but two projects may be opened at once =/ – CuriousGeorge Dec 15 '12 at 21:59
  • 1
    not sure how old it is, but: http://opensource.apple.com/source/CyrusIMAP/CyrusIMAP-191/cyrus_imap/doc/internal/uuid --- "UUIDs are 96 bit (12 byte) numbers, represented on the wire as 24 hex digits" – CuriousGeorge Dec 15 '12 at 22:01
  • I saw that, but Cyrus IMAP isn't an Apple project. They just happen to use it in OS X Server, so they distribute the source. –  Dec 15 '12 at 22:03
  • I would prefer not to just sub in random numbers or truncated UUIDs, but if uniqueness outside of the project was that important, apple probably would have used full UUIDs anyways. – CuriousGeorge Dec 15 '12 at 22:13