{"id":20790374,"url":"https://github.com/paragonie/paserk-php","last_synced_at":"2025-06-15T07:03:00.326Z","repository":{"id":38442510,"uuid":"388910799","full_name":"paragonie/paserk-php","owner":"paragonie","description":"PHP Implementation of PASERK","archived":false,"fork":false,"pushed_at":"2025-01-29T11:40:55.000Z","size":227,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-15T07:02:31.370Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/paragonie.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,"zenodo":null}},"created_at":"2021-07-23T19:49:59.000Z","updated_at":"2025-01-29T14:36:16.000Z","dependencies_parsed_at":"2024-04-28T10:31:13.018Z","dependency_job_id":"fbeac876-a595-4ae3-83c7-371e360d130f","html_url":"https://github.com/paragonie/paserk-php","commit_stats":{"total_commits":72,"total_committers":2,"mean_commits":36.0,"dds":0.02777777777777779,"last_synced_commit":"7777498154903e1cf5455497e9001059e3660b6d"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/paragonie/paserk-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fpaserk-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fpaserk-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fpaserk-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fpaserk-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paragonie","download_url":"https://codeload.github.com/paragonie/paserk-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fpaserk-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259935589,"owners_count":22934384,"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-17T15:34:25.068Z","updated_at":"2025-06-15T07:03:00.277Z","avatar_url":"https://github.com/paragonie.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PASERK (PHP)\n\n[![Build Status](https://github.com/paragonie/paserk-php/actions/workflows/ci.yml/badge.svg)](https://github.com/paragonie/paserk-php/actions)\n[![Latest Stable Version](https://poser.pugx.org/paragonie/paserk/v/stable)](https://packagist.org/packages/paragonie/paserk)\n[![Latest Unstable Version](https://poser.pugx.org/paragonie/paserk/v/unstable)](https://packagist.org/packages/paragonie/paserk)\n[![License](https://poser.pugx.org/paragonie/paserk/license)](https://packagist.org/packages/paragonie/paserk)\n[![Downloads](https://img.shields.io/packagist/dt/paragonie/paserk.svg)](https://packagist.org/packages/paragonie/paserk)\n\nPlatform Agnostic SERialized Keys. **Requires PHP 7.1 or newer.**\n\n## PASERK Specification\n\nThe PASERK Specification can be found [in this repository](https://github.com/paseto-standard/paserk).\n\n## Installing\n\n```terminal\ncomposer require paragonie/paserk\n```\n\n### PASERK Library Versions\n\n* PASERK PHP Version 2\n  * Requires PHP 8.1+\n  * PASETO versions: `v3`, `v4`\n    * This means only the corresponding `k3` and `k4` modes are implemented.\n* [PASERK PHP Version 1](https://github.com/paragonie/paserk-php/tree/v1.x)\n  * Requires PHP 7.1+\n  * PASETO versions: `v1`, `v2`, `v3`, `v4`\n    * This provides a stable reference implementation for the PASERK specification.\n\n## Documentation\n\nSee [this directory](docs) for the documentation.\n\n## Example: Public-key Encryption\n\n### Wrapping\n\n```php\n\u003c?php\nuse ParagonIE\\Paseto\\Builder;\nuse ParagonIE\\Paseto\\Keys\\SymmetricKey;\nuse ParagonIE\\Paseto\\Protocol\\Version4;\nuse ParagonIE\\Paserk\\Operations\\Key\\SealingPublicKey;\nuse ParagonIE\\Paserk\\Types\\Seal;\n\n$version = new Version4();\n\n// First, you need a sealing keypair.\n\n// $sealingSecret = ParagonIE\\Paserk\\Operations\\Key\\SealingSecretKey::generate();\n// $sealingPublic = $sealingSecret-\u003egetPublicKey();\n// var_dump($sealingSecret-\u003eencode(), $sealingPublic-\u003eencode());\n\n$sealingPublic = SealingPublicKey::fromEncodedString(\n    \"vdd1m2Eri8ggYYR5YtnmEninoiCxH1eguGNKe4pes3g\",\n    $version\n);\n$sealer = new Seal($sealingPublic);\n\n// Generate a random one-time key, which will be encrypted with the public key:\n$key = SymmetricKey::generate($version);\n\n// Seal means \"public key encryption\":\n$paserk = $sealer-\u003eencode($key);\n\n// Now let's associate this PASERK with a PASETO that uses the local key:\n$paseto = Builder::getLocal($key, $version)\n    -\u003ewith('test', 'readme')\n    -\u003ewithExpiration(\n        (new DateTime('NOW'))\n            -\u003eadd(new DateInterval('P01D'))\n    )\n    -\u003ewithFooterArray(['kid' =\u003e $sealer-\u003eid($key)])\n    -\u003etoString();\n\nvar_dump($paserk, $paseto);\n```\n\n### Unwrapping\n\n```php\n\u003c?php\nuse ParagonIE\\Paseto\\Protocol\\Version4;\nuse ParagonIE\\Paserk\\Operations\\Key\\SealingSecretKey;\nuse ParagonIE\\Paserk\\Types\\Lid;\nuse ParagonIE\\Paserk\\Types\\Seal;\nuse ParagonIE\\Paseto\\Parser as PasetoParser;\nuse ParagonIE\\Paseto\\ProtocolCollection;\n\n$version = new Version4();\n\n// From previous example:\n$paserk = \"k4.seal.F2qE4x0JfqT7JYhOB7S12SikvLaRuEpxRkgxxHfh4hVpE1JfwIDnreuhs9v5gjoBl3WTVjdIz6NkwQdqRoS2EDc3yGvdf_Da4K1xUSJ8IVTn4HQeol5ruYwjQlA_Ph4N\";\n$paseto = \"v4.local.hYG-BfpTTM3bb-xZ-q5-w77XGayS4WA8kA5R5ZL85u3nzgrWba5NdqgIouFn71CJyGAff1eloirzz3sWRdVXnDeSIYxXDIerNkbLI5ALn24JehhSLKrv8R2-yhfo_XZF9XEASXtwrOyMNjeEAan5kqO6Dg.eyJraWQiOiJrNC5saWQueDAycGJDRmhxU1Q4endnbEJyR3VqWE9LYU5kRkJjY1dsTFFRN0pzcGlZM18ifQ\";\n\n// Keys for unsealing:\n$sealingSecret = SealingSecretKey::fromEncodedString(\n    \"j043XiZTuGLleB0kAy8f3Tz-lEePK_ynEWPp4OyB-lS913WbYSuLyCBhhHli2eYSeKeiILEfV6C4Y0p7il6zeA\",\n    $version\n);\n$sealingPublic = $sealingSecret-\u003egetPublicKey();\n\n// Unwrap the sytmmetric key for `v4.local.` tokens.\n$sealer = new Seal($sealingPublic, $sealingSecret);\n$unwrapped = $sealer-\u003edecode($paserk);\n\n// Parse the PASETO\n$parsed = PasetoParser::getLocal($unwrapped, ProtocolCollection::v4())\n    -\u003eparse($paseto);\n\n// Get the claims from the parsed and validated token:\nvar_dump($parsed-\u003egetClaims());\n/*\narray(2) {\n  [\"test\"]=\u003e\n  string(6) \"readme\"\n  [\"exp\"]=\u003e\n  string(25) \"2038-01-19T03:14:08+00:00\"\n}\n*/\n\n// Observe the Key ID is the same as the value stored in the footer.\nvar_dump(Lid::encode($version, $paserk));\nvar_dump($parsed-\u003egetFooterArray()['kid']);\n/*\nstring(51) \"k4.lid.x02pbCFhqST8zwglBrGujXOKaNdFBccWlLQQ7JspiY3_\"\nstring(51) \"k4.lid.x02pbCFhqST8zwglBrGujXOKaNdFBccWlLQQ7JspiY3_\"\n*/\n```\n\n## PASERK Feature Coverage\n\n- [x] [`lid`](https://github.com/paseto-standard/paserk/blob/master/types/lid.md) \n- [x] [`local`](https://github.com/paseto-standard/paserk/blob/master/types/local.md) \n- [x] [`seal`](https://github.com/paseto-standard/paserk/blob/master/types/seal.md)\n- [x] [`local-wrap`](https://github.com/paseto-standard/paserk/blob/master/types/local-wrap.md)\n    - [x] [`pie`](https://github.com/paseto-standard/paserk/blob/master/operations/Wrap/pie.md)\n- [x] [`local-pw`](https://github.com/paseto-standard/paserk/blob/master/types/local-pw.md)\n    * (Requires ext-sodium for v2/v4 keys, due to Argon2id)\n- [x] [`pid`](https://github.com/paseto-standard/paserk/blob/master/types/pid.md)\n- [x] [`public`](https://github.com/paseto-standard/paserk/blob/master/types/public.md)\n- [x] [`secret`](https://github.com/paseto-standard/paserk/blob/master/types/secret.md)\n- [x] [`secret-wrap`](https://github.com/paseto-standard/paserk/blob/master/types/secret-wrap.md)\n    - [x] [`pie`](https://github.com/paseto-standard/paserk/blob/master/operations/Wrap/pie.md)\n- [x] [`secret-pw`](https://github.com/paseto-standard/paserk/blob/master/types/secret-pw.md)\n    * (Requires ext-sodium for v2/v4 keys, due to Argon2id)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparagonie%2Fpaserk-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparagonie%2Fpaserk-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparagonie%2Fpaserk-php/lists"}