{"id":21189389,"url":"https://github.com/artnum/strid","last_synced_at":"2025-06-30T12:37:37.339Z","repository":{"id":121157891,"uuid":"93950007","full_name":"artnum/strid","owner":"artnum","description":"Generate random short identifier in base36 with crc","archived":false,"fork":false,"pushed_at":"2017-06-12T14:20:52.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-15T16:13:41.951Z","etag":null,"topics":["base36","crc-8","crc8","id","random","shorturl","text"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/artnum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-10T15:59:40.000Z","updated_at":"2017-06-10T16:10:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"31d2cedb-98d4-42a5-b25d-5746032f0fbe","html_url":"https://github.com/artnum/strid","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/artnum/strid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artnum%2Fstrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artnum%2Fstrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artnum%2Fstrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artnum%2Fstrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artnum","download_url":"https://codeload.github.com/artnum/strid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artnum%2Fstrid/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262775021,"owners_count":23362428,"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":["base36","crc-8","crc8","id","random","shorturl","text"],"created_at":"2024-11-20T18:52:09.685Z","updated_at":"2025-06-30T12:37:37.305Z","avatar_url":"https://github.com/artnum.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"STRID\n=====\n\nGenerate random id 10 char long, by default. Uses base 36 encoding and include a checksum. It can be useful for application that need to send id through HTTP or any character-based protocol.\n\nUsage\n-----\n\nInitialize the random number generator (use drand48()) by passing any string to strid_init(). Initialization with a static string will produce predictible results. You don't need to initialize, just you should.\n\n    int main(void) {\n        Strid myId;\n\n        strid_init(\"Not So Random String\");\n        strid_generate_random(myId);\n\n        printf(\"%s\\n\", myId);\n\n        return 0;\n    }\n\nYou can prefix your ID with strid_generate_prefix().\n\n\tint main(void) {\n\t\t/* ... */\n\t\t\n\t\tstrid_generate_prefix(myId, \"hostname.example.com\");\n\t\t\n\t\t/* ... */\n\t}\n\nIf the id comes from an extern source, you might want to verify it.\n\n    int main(void) {\n        /* ... */\n\n        if(strid_valid(externId)) {\n            printf(\"Valid ID\");\n        }\n\n        /* ... */\n    }\n\nTwo id can be compared with strcmp but, in case characters have been lowered, you might well use strid_equal.\n\n    int main(void) {\n    \n        /* ... */\n\n        if(strid_equal(Id1, Id2)) {\n            printf(\"ID1 equals ID2\");\n        }\n\n        /* ... */\n        \n    }\n\nPlease note that strid_equal doesn't validate the id at any point. So check first both ids with strid_valid and then strid_equal.\n\nYou can copy an id into another id with strid_copy.\n\n    int main(void) {\n        /* ... */\n\n       strid_copy(idDest, idSource);\n\n       /* ... */\n    }\n\nIt's just a memcpy, see in strid.h :\n\n    #define strid_copy(dest, src)           memcpy((dest), (src), STRID_MAX_SIZE)\n\nLicense\n-------\n\nBSD 2-clauses, see LICENSE.txt\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartnum%2Fstrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartnum%2Fstrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartnum%2Fstrid/lists"}