{"id":26063278,"url":"https://github.com/edgio/php-ectoken","last_synced_at":"2026-04-25T03:43:57.697Z","repository":{"id":46182559,"uuid":"349230527","full_name":"Edgio/php-ectoken","owner":"Edgio","description":"PHP implementation of ectoken","archived":false,"fork":false,"pushed_at":"2022-06-23T03:13:56.000Z","size":53,"stargazers_count":0,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2023-02-26T22:46:52.666Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","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/Edgio.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}},"created_at":"2021-03-18T22:11:23.000Z","updated_at":"2022-08-10T23:37:48.000Z","dependencies_parsed_at":"2022-09-23T06:01:06.702Z","dependency_job_id":null,"html_url":"https://github.com/Edgio/php-ectoken","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edgio%2Fphp-ectoken","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edgio%2Fphp-ectoken/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edgio%2Fphp-ectoken/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edgio%2Fphp-ectoken/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Edgio","download_url":"https://codeload.github.com/Edgio/php-ectoken/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242580857,"owners_count":20153018,"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":"2025-03-08T16:34:29.190Z","updated_at":"2025-12-24T03:47:24.211Z","avatar_url":"https://github.com/Edgio.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Native PHP ECToken Generator\n\nThis is a native PHP implementation of the Edgio Token Generator that does\nnot require a PHP extension to operate, making it suitable for environments in\nwhich PHP extensions are not available.\n\nAdditional ECToken parameter management has been included in order to assist\nusers of this library to construct parameter strings for encrypting.\n\n## Requirements\n\nEfforts have been made to ensure that this code will operate properly on PHP \n5.6+ or PHP 7+, with or without mbstring or openssl support.\n\n- Composer (\u003chttps://getcomposer.org\u003e) is required for dependency management\n\n## Installation\n\nClone or download this repository and run `composer install` from the direcory\ncontaining `composer.json`\n\n_Note:_ `composer install` should be performed in an environment closely\nresembling the production environment because dependant library versions will be \nchosen based on the PHP version encountered during install.\n\n## Usage\n\n```\nrequire_once('path/to/autoload.php');\n\n$key = \"12345678\";\n\n// Configure the token\n$token = new ECToken3\\ECToken();\n$token\n  -\u003eaddValue('ec_clientip', '111.11.111.11')\n  -\u003eaddValue('ec_expire', 1185943200)\n  -\u003eaddValue('ec_country_allow', 'US')\n  -\u003eaddValue('ec_country_allow', 'CA')\n  -\u003eaddValue('ec_ref_allow', 'ec1.com');\n\n// Set up the encryption\n$encryptor = new ECToken\\Crypto($key);\n\n// Generate and encrypt the token\n$ectoken = $encryptor-\u003eencrypt($token-\u003eencode());\n\necho $ectoken;\n```\n\nThe library contains a mechanism to configure tokens using the simple ECToken\nclass. Paremeter names and values are validated for proper content based on the\n_VDMS Token-Based Authentication Administration Guide_. Parameter definitions are\naware of whether each parameter can accommodate multiple values.\n\nA parser is provided for consuming decrypted ectokens back into this data\nstructure.  For example:\n\n```\nrequire_once('path/to/autoload.php);\n\n$key = '12345678';\n$ectoken = '3JfiJSVMLupuU6JIk88cjm9kmr8A0ERvcB8WH_8n-9pJKPsBf1l7QNnRQQ6H4M4gysS3J3SRJtAqUQhHmt6HWnaAV-UejGp38iQxd3uZgYnYLWiompbbQTFc5fwu9-x-mtwnsQ5bz2W-ma1LPlj9ZPdXGxN9Pg';\n\n$encryptor = ECToken3\\Crypto($key);\n\n$token = new ECToken3\\ECToken();\n\n$token-\u003edecode($encryptor-\u003edecrypt($ectoken));\n\nforeach ($token-\u003egetParameters() as $name =\u003e $parameter) {\n  print(\"$name: \" . implode(', ', $parameter-\u003egetValues()) . \"\\n\");\n}\n\n```\n\nOutput:\n```\nec_clientip: 111.11.111.11\nec_expire: 1185943200\nec_country_allow: US, CA\nec_ref_allow: ec1.com\n```\n\n## Migrating from php-ectoken\n\nExisting code bases should be simple to migrate from php extension versions of\nphp-ectoken.\n\n1. Remove any checks for the `ectoken` PHP extension (e.g. `extension_loaded('ectoken')`)\n2. Refactor calls to `ectoken_encrypt_token` or `ectoken_decrypt_token` as above or include the following shim:\n\n```\nrequire_once('path/to/autoload.php');\n\nfunction ectoken_encrypt_token($key, $input) {\n  $encryptor = new ECToken\\Crypto($key);\n  return $encryptor-\u003eencrypt($input);\n}\n\nfunction ectoken_decrypt_token($key, $input) {\n  $encryptor = new ECToken\\Crypto($key);\n  return $encryptor-\u003edecrypt($input);\n}\n```\n\n## Libraries used directly by php-native-ectoken\n\nThese libraries are used directly:\n\n- php-aes-gcm: AES GCM (Galois Counter Mode) PHP Implementation \u003chttps://github.com/Spomky-Labs/php-aes-gcm\u003e\n- random_compat: PHP 5.x polyfill for `random_bytes()` and `random_int()` \u003chttps://github.com/paragonie/random_compat\u003e\n- constant_time_encoding: Constant-Time Character Encoding in PHP Projects \u003chttps://github.com/paragonie/constant_time_encoding\u003e\n- polyfill-mbstring: Symfony Polyfill / Mbstring \u003chttps://github.com/symfony/polyfill\u003e\n- Respect\\Validation: Validation library \u003chttps://github.com/Respect/Validation\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgio%2Fphp-ectoken","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedgio%2Fphp-ectoken","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgio%2Fphp-ectoken/lists"}