{"id":20270937,"url":"https://github.com/mackron/uuid","last_synced_at":"2025-04-11T04:20:50.130Z","repository":{"id":37029755,"uuid":"458519034","full_name":"mackron/uuid","owner":"mackron","description":"UUID generator.","archived":false,"fork":false,"pushed_at":"2022-06-20T23:07:07.000Z","size":90,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T02:36:41.078Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mackron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-12T12:43:58.000Z","updated_at":"2024-12-25T12:37:15.000Z","dependencies_parsed_at":"2022-08-18T00:15:48.536Z","dependency_job_id":null,"html_url":"https://github.com/mackron/uuid","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mackron%2Fuuid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mackron%2Fuuid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mackron%2Fuuid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mackron%2Fuuid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mackron","download_url":"https://codeload.github.com/mackron/uuid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248340139,"owners_count":21087393,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T12:35:03.584Z","updated_at":"2025-04-11T04:20:50.080Z","avatar_url":"https://github.com/mackron.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch4 align=\"center\"\u003eUUID Generator\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://discord.gg/9vpqbjU\"\u003e\u003cimg src=\"https://img.shields.io/discord/712952679415939085?label=discord\u0026logo=discord\" alt=\"discord\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://twitter.com/mackron\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/mackron?style=flat\u0026label=twitter\u0026color=1da1f2\u0026logo=twitter\" alt=\"twitter\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nThis supports all UUID versions defined in RFC 4122 except version 2. For version 3 and 5 you will\nneed to provide your own MD5 and SHA-1 hashing implementation by defining the some macros before\nthe implementation of this library. Below is an example:\n\n    #define UUID_MD5_CTX_TYPE               md5_context\n    #define UUID_MD5_INIT(ctx)              md5_init(ctx)\n    #define UUID_MD5_FINAL(ctx, digest)     md5_finalize(ctx, (unsigned char*)(digest))\n    #define UUID_MD5_UPDATE(ctx, src, sz)   md5_update(ctx, src, (size_t)(sz))\n\n    #define UUID_SHA1_CTX_TYPE              sha1_context\n    #define UUID_SHA1_INIT(ctx)             sha1_init(ctx)\n    #define UUID_SHA1_FINAL(ctx, digest)    sha1_finalize(ctx, (unsigned char*)(digest))\n    #define UUID_SHA1_UPDATE(ctx, src, sz)  sha1_update(ctx, src, (size_t)(sz));\n\nA public domain MD5 and SHA-1 hashing implmentation can be found here:\n\n  * https://github.com/mackron/md5\n  * https://github.com/mackron/sha1\n\nThese are included as submodules in this repository for your convenience but need not be used if\nyou would rather use a different implementation. If you want to use these libraries, instead of\ndefining the above macros you can just include them before the implementation like so and they'll\nautomatically be detected:\n\n    #include \"external/md5/md5.c\"    // \u003c-- Enables version 3.\n    #include \"external/sha1/sha1.c\"  // \u003c-- Enables version 5.\n\n    #define UUID_IMPLEMENTATION\n    #include \"uuid.h\"\n\nThere is no need to link to anything with this library. You can use UUID_IMPLEMENTATION to define\nthe implementation section, or you can use uuid.c if you prefer a traditional header/source pair.\n\nUse the following APIs to generate a UUID:\n\n    uuid1(unsigned char* pUUID, uuid_rand* pRNG);\n    uuid3(unsigned char* pUUID, const unsigned char* pNamespaceUUID, const char* pName);\n    uuid4(unsigned char* pUUID, uuid_rand* pRNG);\n    uuid5(unsigned char* pUUID, const unsigned char* pNamespaceUUID, const char* pName);\n    uuid_ordered(unsigned char* pUUID, uuid_rand* pRNG);\n\nIf you want to use a time-based ordered UUID you can use `uuid_ordered()`. Note that this is not\nofficially allowed by RFC 4122. This does not encode a version as it would break ordering.\n\nUse the following APIs to format the UUID as a string:\n\n    uuid_format(char* pDst, size_t dstCap, const unsigned char* pUUID);\n\nThe size of the UUID buffer must be at least `UUID_SIZE` (16 bytes). For formatted strings the\ndestination buffer should be at least `UUID_SIZE_FORMATTED`.\n\nExample:\n\n    unsigned char uuid[UUID_SIZE];\n    uuid4(uuid, NULL);\n\n    char str[UUID_SIZE_FORMATTED];\n    uuid_format(str, sizeof(str), uuid);\n\nWith the code above the default random number generator will be used (second parameter). If you\nwant to use your own random number generator, you can pass in a random number generator:\n\n    uuid4(uuid, \u0026myRNG);\n\nThe default random number generator is cryptorand: https://github.com/mackron/cryptorand. If you\nhave access to the implementation section, you can make use of this easily:\n\n    uuid_cryptorand rng;\n    uuid_cryprorand_init(\u0026rng);\n\n    for (i = 0; i \u003c count; i += 1) {\n        uuid4(uuid, \u0026rng);\n\n        // ... do something with the UUID ...\n    }\n\n    uuiid_cryptorand_uninit(\u0026rng);\n\nAlternatively you can implement your own random number generator by inheritting from\n`uuid_rand_callbacks` like so:\n\n    typedef struct\n    {\n        uuid_rand_callbacks cb;\n    } my_rng;\n\n    static uuid_result my_rng_generate(uuid_rand* pRNG, void* pBufferOut, size_t byteCount)\n    {\n        my_rng* pMyRNG = (my_rng*)pRNG;\n\n        // ... do random number generation here. Output byteCount bytes to pBufferOut.\n\n        return UUID_SUCCESS;\n    }\n\n    ...\n\n    // Initialize your random number generator.\n    my_rng myRNG;\n    rng.cb.onGenerator = my_rng_generate;\n\n    // Generate your GUID.\n    uuid4(uuid, \u0026myRNG);\n\nYou can disable cryptorand and compile time with `UUID_NO_CRYPTORAND`, but by doing so you will be\nrequired to specify your own random number generator. This is useful if you already have a good\nquality random number generator in your code base and want to save a little bit of space.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmackron%2Fuuid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmackron%2Fuuid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmackron%2Fuuid/lists"}