{"id":17229169,"url":"https://github.com/causefx/unique-id","last_synced_at":"2025-10-08T17:10:02.982Z","repository":{"id":114452147,"uuid":"103581686","full_name":"causefx/unique-id","owner":"causefx","description":"Creates unique static ID","archived":false,"fork":false,"pushed_at":"2016-03-03T19:51:42.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T18:52:33.940Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/causefx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-09-14T21:04:48.000Z","updated_at":"2019-12-11T03:54:29.000Z","dependencies_parsed_at":"2023-06-07T23:15:32.340Z","dependency_job_id":null,"html_url":"https://github.com/causefx/unique-id","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/causefx/unique-id","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/causefx%2Funique-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/causefx%2Funique-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/causefx%2Funique-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/causefx%2Funique-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/causefx","download_url":"https://codeload.github.com/causefx/unique-id/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/causefx%2Funique-id/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278981518,"owners_count":26079640,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-15T04:46:11.449Z","updated_at":"2025-10-08T17:10:02.974Z","avatar_url":"https://github.com/causefx.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## unique-id\r\n\r\n[![Latest Stable Version](https://poser.pugx.org/sak32009/unique-id/v/stable)](https://packagist.org/packages/sak32009/unique-id)\r\n[![Total Downloads](https://poser.pugx.org/sak32009/unique-id/downloads)](https://packagist.org/packages/sak32009/unique-id)\r\n[![Latest Unstable Version](https://poser.pugx.org/sak32009/unique-id/v/unstable)](https://packagist.org/packages/sak32009/unique-id)\r\n[![License](https://poser.pugx.org/sak32009/unique-id/license)](https://packagist.org/packages/sak32009/unique-id)\r\n[![Codacy Badge](https://api.codacy.com/project/badge/grade/c3e0f83acf8c4919a5fc4a756e9d56b7)](https://www.codacy.com/app/Sak32009/unique-id)\r\n\r\n## Description\r\n\r\nCreates unique static ID.\r\n\r\n## Requirements\r\n\r\n* PHP \u003e= `5.5`\r\n\r\n## Installation\r\n\r\n### [Composer](https://getcomposer.org/) (Recommended)\r\n\r\nRun the command the following from within your project directory:\r\n\r\n```\r\ncomposer require sak32009/unique-id\r\n```\r\n\r\n```php\r\ninclude \"vendor/autoload.php\";\r\n```\r\n\r\n### Direct download\r\n\r\nIf you want to install manually, on the main page you can download or clone the repo.\r\n\r\n```php\r\ninclude \"src/sak32009/unique-id.php\";\r\n```\r\n\r\n## Usage\r\n\r\n```php\r\n$uniqueID = new sak32009\\uniqueID;\r\n$uniqueID-\u003esetOption('hash_salt', 'my_private_key');\r\n```\r\n\r\n## Example\r\n\r\n```php\r\n$cookie = $_COOKIE['cookie'];\r\n\r\nif(strlen($cookie) \u003e 0){\r\n\r\n    if($uniqueID-\u003everify($cookie)){\r\n\r\n        echo \"OK! Hash: \" . $cookie;\r\n\r\n    }else{\r\n\r\n        echo \"Hash invalid\";\r\n\r\n    }\r\n\r\n}else{\r\n\r\n    $hash = $uniqueID-\u003egenerateID();\r\n\r\n    setcookie('cookie', $hash, (time()+60*60*24*30));\r\n\r\n    echo \"Reload page\";\r\n\r\n}\r\n```\r\n\r\n## Functions\r\n\r\n### Generate ID\r\n\r\nFor generate ID use `$uniqueID-\u003egenerateID()`:\r\n\r\n```php\r\n$uniqueID-\u003egenerateID();\r\n```\r\n\r\n### Verify hash\r\n\r\nFor verify hash use `$uniqueID-\u003everify(hash)`:\r\n\r\n```php\r\n$uniqueID-\u003everify('$2y$10$pBxDPcYxwy9C/NAhgCuoHun5YeTqY/1CTZBT71R4cY3L8xFys2Q5G');\r\n```\r\n\r\n**Note**: Use this to check if hash corresponds to the user.\r\n\r\n### Set options\r\n\r\nFor set options use `$uniqueID-\u003esetOption(key, val)`:\r\n\r\n```php\r\n$uniqueID-\u003esetOption('hash_salt', 'my_private_key');\r\n```\r\n\r\n**Note**: See `options` section.\r\n\r\n### Add data\r\n\r\nFor add more data use `$uniqueID-\u003eaddData(str)`:\r\n\r\n```php\r\n$uniqueID-\u003eaddData($_SERVER['SCRIPT_NAME']);\r\n```\r\n\r\n**Note**: This makes the ID much safer.\r\n\r\n## Options\r\n\r\n**hash_salt** Default: *null*, Type: string\r\n\r\nSee this link [WIKIPEDIA](https://en.wikipedia.org/wiki/Salt_%28cryptography%29), in short is the private key.\r\n\r\n```php\r\n$uniqueID-\u003esetOption('hash_salt', 'my_private_key');\r\n```\r\n\r\n## License\r\n\r\nThis software is distributed under the [MIT](https://opensource.org/licenses/MIT) license. Please read [LICENSE](LICENSE) for information on the software availability and distribution.\r\n\r\n## Changelog\r\n\r\nSee the [releases pages](https://github.com/Sak32009/unique-id/releases) for a history of releases and highlights for each release.\r\n\r\n## Versioning\r\n\r\nMaintained under the Semantic Versioning guidelines as much as possible. Releases will be numbered with the following format:\r\n\r\n`\u003cmajor\u003e.\u003cminor\u003e.\u003cpatch\u003e`\r\n\r\nFor more information, please visit [SEMVER](http://semver.org).\r\n\r\n## Author\r\n\r\n* Sak32009 `\u003chttps://github.com/Sak32009\u003e`\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcausefx%2Funique-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcausefx%2Funique-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcausefx%2Funique-id/lists"}