{"id":18794560,"url":"https://github.com/effectra/security","last_synced_at":"2025-10-06T02:58:26.854Z","repository":{"id":168810772,"uuid":"644606851","full_name":"effectra/security","owner":"effectra","description":"Effectra\\Security is a PHP library that provides security-related functionalities such as hashing, password management, CSRF token handling, and token generation.","archived":false,"fork":false,"pushed_at":"2023-06-19T17:40:17.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-21T16:13:06.356Z","etag":null,"topics":["csrf-protection","hash","hash-password","jwt","php","security","token","xss"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/effectra.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-23T22:01:05.000Z","updated_at":"2023-05-23T22:28:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"20164396-f323-4a21-b355-9eb7be71ae73","html_url":"https://github.com/effectra/security","commit_stats":null,"previous_names":["effectra/security"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/effectra/security","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fsecurity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fsecurity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fsecurity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fsecurity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/effectra","download_url":"https://codeload.github.com/effectra/security/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fsecurity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278551496,"owners_count":26005389,"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-06T02:00:05.630Z","response_time":65,"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":["csrf-protection","hash","hash-password","jwt","php","security","token","xss"],"created_at":"2024-11-07T21:29:46.984Z","updated_at":"2025-10-06T02:58:26.840Z","avatar_url":"https://github.com/effectra.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Effectra Security\n\nEffectra\\Security is a PHP library that provides security-related functionalities such as hashing, password management, CSRF token handling, and token generation.\n\n## Features\n\n- Hashing: Securely hash data using various algorithms.\n- Password Management: Generate and verify hashed passwords.\n- CSRF Protection: Generate and validate CSRF tokens for web applications.\n- Token Generation: Create and decode JSON Web Tokens (JWT).\n\n## Requirements\n\n- PHP 7.0 or higher\n\n## Installation\n\nYou can install the Effectra\\Security library via Composer. Run the following command in your project directory:\n\n```bash\ncomposer require effectra/security\n```\n\n## Usage\n\n### Hashing\n\nThe `Effectra\\Security\\Hash` class provides methods for hashing data using HMAC algorithms.\n\nExample usage:\n\n```php\nuse Effectra\\Security\\Hash;\n\n$data = 'Hello, World!';\n$key = 'secret-key';\n\n$hash = Hash::set($data, $key);\necho \"Hashed value: \" . $hash;\n```\n\n### Password Management\n\nThe `Effectra\\Security\\Hash` class also includes methods for securely managing passwords.\n\nExample usage:\n\n```php\nuse Effectra\\Security\\Hash;\n\n$password = 'password123';\n\n$hashedPassword = Hash::setPassword($password);\necho \"Hashed password: \" . $hashedPassword;\n\n$isPasswordValid = Hash::verifyPassword($password, $hashedPassword);\nif ($isPasswordValid) {\n    echo \"Password is valid.\";\n} else {\n    echo \"Password is invalid.\";\n}\n```\n\n### CSRF Protection\n\nThe `Effectra\\Security\\Csrf` class provides functionality for generating and validating CSRF tokens.\n\nExample usage:\n\n```php\nuse Effectra\\Security\\Csrf;\nuse Effectra\\Session\\Session; // Replace with your own session implementation\n\n// Initialize the CSRF class with a session instance\n$session = new Session();\n$csrf = new Csrf($session);\n\n// Generate and insert a CSRF token in your HTML form\n$html = '\u003cform\u003e';\n$html .= $csrf-\u003einsertHiddenToken();\n$html .= '\u003cinput type=\"submit\" value=\"Submit\"\u003e';\n$html .= '\u003c/form\u003e';\n\necho $html;\n\n// Validate the CSRF token on form submission\nif ($csrf-\u003evalidate()) {\n    echo \"CSRF token is valid.\";\n} else {\n    echo \"CSRF token is invalid.\";\n}\n```\n\n### Token Generation\n\nThe `Effectra\\Security\\Token` class allows you to generate and decode JSON Web Tokens (JWT).\n\nExample usage:\n\n```php\nuse Effectra\\Security\\Token;\n\n$data = ['user_id' =\u003e 123];\n\n$config = (object) [\n    'issued_at' =\u003e time(),\n    'expirationTime' =\u003e time() + 3600, // Expiration time 1 hour from now\n    'issuer' =\u003e 'example.com',\n    'key' =\u003e 'your-secret-key'\n];\n\n$token = new Token();\n$encodedToken = $token-\u003eset($data, $config);\necho \"Encoded token: \" . $encodedToken;\n\n$decodedToken = $token-\u003eget($encodedToken, $config);\necho \"Decoded token: \";\nprint_r($decodedToken);\n```\n\n## Contributing\n\nContributions are welcome! Feel free to submit bug reports, feature requests, or pull requests on the [GitHub repository](https://github.com/effectra/security).\n\n## License\n\nEffectra\\Security is licensed under the [MIT License](https://opensource.org/licenses/MIT).\n\n## Credits\n\nEffectra\\Security is developed and maintained by [Effectra](https://www.effectra.com).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fsecurity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feffectra%2Fsecurity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fsecurity/lists"}