{"id":16296703,"url":"https://github.com/hernandev/zodium","last_synced_at":"2025-04-09T13:29:45.312Z","repository":{"id":83055197,"uuid":"130594366","full_name":"hernandev/zodium","owner":"hernandev","description":"Zodium: OOP wrapper for PHP 7.2+ Sodium Extension (libsodium).","archived":false,"fork":false,"pushed_at":"2018-04-23T07:34:44.000Z","size":195,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T07:38:48.371Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"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/hernandev.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":"2018-04-22T18:10:30.000Z","updated_at":"2022-12-21T19:23:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"c310b255-21a0-4425-9d7a-5bf848d35f2a","html_url":"https://github.com/hernandev/zodium","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/hernandev%2Fzodium","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernandev%2Fzodium/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernandev%2Fzodium/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernandev%2Fzodium/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hernandev","download_url":"https://codeload.github.com/hernandev/zodium/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248048795,"owners_count":21039097,"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-10-10T20:23:42.957Z","updated_at":"2025-04-09T13:29:45.294Z","avatar_url":"https://github.com/hernandev.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zodium\n\n**Zodium** is an object-oriented wrapper for the `libsodium` bindings of PHP.\n\nThe name **Z**odium is due the fact of this extension being developed with [Zephir](https://zephir-lang.com/).\n\nThe original [sodium](https://github.com/jedisct1/libsodium-php) extension is still required, Zodium does not\nbind the C library, this extension is a wrapper for the already existing, non-OOP extension.\n\n#### Usage:\n\nThe library aims to be really easy to use.\n\n##### Hashing:\n\n```php\n\u003c?php\n// alias the GenericHash class.\nuse Zodium\\Hash\\GenericHash;\n\n// start a key-less hasher instance.\n$hasher = new GenericHash();\n\n// hash a value without a hashing key.\n$hash = $hasher-\u003ehash('foo');\n// string(64) \"93a0e84a8cdd416626...\n\n// generate a hashing key.\n$key = GenericHash::generateKey();\n// string(64) \"62009feb496f0...\n\n// start a new hasher with the hashing key.\n$hasher = new GenericHasher($key);\n\n$hash = $hasher-\u003ehash('foo');\n// string(64) \"714ee3a37cf69bb3aee17...\n\n// start a custom length hash output instance.\n$hasher = new GenericHash($key, 64);\n$hash = $hasher-\u003ehash('foo');\n// string(128) \"d94315288e268d813e...\n\n// multi-part signature..\n$hasher-\u003eadd(\"part1\");\n$hasher-\u003eadd(\"part2\");\n\n// get the final hash from the parts included.\n$hash = $hasher-\u003ehash();\n```\n\n##### AEAD:\n\n```php\n\u003c?php\n// aliases.\nuse Zodium\\AEAD\\Cipher;\n\n// start a AEAD cipher instance on the ChaCha20-Poly1305 construction.\n$cipher = new Cipher('CHACHA20POLY1305');\n\n// get a private secret key.\n$cipher-\u003esetSecretKey(Cipher::generateSecretKey());\n\n// encrypt the secret data with some associated public data.\n$encryptedPayload = $cipher-\u003eencrypt('message', 'associated-data');\n\n// decrypt the original message from the payload.\n$original = $cipher-\u003edecrypt($encryptedPayload);\n```\n\n##### SecretBox:\n\n```php\n\u003c?php\n\n// aliases.\nuse Zodium\\SecretBox\\SecretBox;\nuse Zodium\\SecretBox\\EncryptedPayload;\n\n// generate a secret key for use with the SecretBox.\n$key = SecretBox::generateSecretKey();\n\n// start a SecretBox instance.\n$box = new SecretBox($key);\n\n// encrypt some data, and receive a EncryptPayload instance as return.\n$payload = $box-\u003eencrypt('some-data-as-string');\n\n// encode the payload for transmission or storage:\n$payloadString = $payload-\u003eencode();\n\n// reverse the payload from string into instance.\n$payload = EncryptedPayload::decode($payloadString);\n\n// decrypt.\n$originalData = $box-\u003edecrypt($payload);\n\n// extras:\n// you can encrypt any serializable value on PHP.\n$payload = $box-\u003eencrypt(new Datetime());\n// the value will be unserialized back on the original type!.\n$dateTimeInstance = $box-\u003edecrypt($payload);\n\n```\n\n#### Roadmap:\n\nCurrent features to be included are:\n\n- Constant-time helpers and safe evaluation of sensitive values.\n- Public-key Encryption.\n- Stand-alone message authentication.\n- Bind Zephir optimizers to calls on the libsodium directly.\n- Documentation\n- .phpt tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhernandev%2Fzodium","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhernandev%2Fzodium","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhernandev%2Fzodium/lists"}