{"id":16641223,"url":"https://github.com/barseghyanartur/skaphp","last_synced_at":"2026-04-29T03:05:15.229Z","repository":{"id":46029227,"uuid":"403767849","full_name":"barseghyanartur/skaphp","owner":"barseghyanartur","description":"Lets you easily sign data, using symmetric-key algorithm encryption. Allows you to validate signed data and identify possible validation errors. Uses sha/hmac for signature encryption. Comes with shortcut functions for signing (and validating) dictionaries.","archived":false,"fork":false,"pushed_at":"2023-11-29T10:40:40.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-01T05:25:29.019Z","etag":null,"topics":["data-encryption","data-hash","encryption","php-library","security"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/barseghyanartur/ska","language":"PHP","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/barseghyanartur.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-09-06T21:57:59.000Z","updated_at":"2021-11-19T01:35:45.000Z","dependencies_parsed_at":"2022-07-26T05:32:33.906Z","dependency_job_id":null,"html_url":"https://github.com/barseghyanartur/skaphp","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/barseghyanartur/skaphp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barseghyanartur%2Fskaphp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barseghyanartur%2Fskaphp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barseghyanartur%2Fskaphp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barseghyanartur%2Fskaphp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barseghyanartur","download_url":"https://codeload.github.com/barseghyanartur/skaphp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barseghyanartur%2Fskaphp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32408447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T02:37:21.628Z","status":"ssl_error","status_checked_at":"2026-04-29T02:36:50.947Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["data-encryption","data-hash","encryption","php-library","security"],"created_at":"2024-10-12T07:45:53.350Z","updated_at":"2026-04-29T03:05:15.213Z","avatar_url":"https://github.com/barseghyanartur.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ska\n\nLets you easily sign data, using symmetric-key algorithm encryption. Allows\nyou to validate signed data and identify possible validation errors. Uses\nsha/hmac for signature encryption. Comes with shortcut functions for signing (and\nvalidating) dictionaries (associative arrays).\n\n[![Packagist version](https://img.shields.io/packagist/v/barseghyanartur/ska.svg?logo=php\u0026logoColor=white\u0026style=flat-square)](https://packagist.org/packages/barseghyanartur/ska)\n[![Supported PHP versions](https://img.shields.io/packagist/php-v/barseghyanartur/ska.svg?logo=php\u0026logoColor=white\u0026style=flat-square)](https://packagist.org/packages/barseghyanartur/ska)\n[![Build Status](https://github.com/barseghyanartur/skaphp/actions/workflows/tests.yml/badge.svg)](https://github.com/barseghyanartur/skaphp/actions)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/barseghyanartur/skaphp/#License)\n\n## Key concepts\n\nHosts, that communicate with each other, share the Secret Key, which is used\nto sign data (requests). Secret key is never sent around.\n\nOne of the cases is signing of HTTP requests. Each (HTTP) request is signed\non the sender side using the shared Secret Key and as an outcome produces the\ntriple (`signature`, `auth_user`, `valid_until`) which are used to sign\nthe requests.\n\n-   `signature` (`string`): Signature generated.\n-   `auth_user` (`string`): User making the request. Can be anything.\n-   `valid_until` (`float` or `string`): Signature expiration time (Unix timestamp).\n\nOn the recipient side, (HTTP request) data is validated using the shared\nSecret Key. It's being checked whether signature is valid and not expired.\n\n```\n    ┌─────────────┐           Data              ┌─────────────┐\n    │   Host 1    ├────────────────────────────\u003e│   Host 2    │\n    │ ─────────── │                             │ ─────────── │\n    │ secret key  │                             │ secret key  │\n    │ 'my-secret' │\u003c────────────────────────────┤ 'my-secret' │\n    └─────────────┘           Data              └─────────────┘\n```\n\n## Features\n\n-   Sign dictionaries.\n-   Validate signed dictionaries.\n\n## Prerequisites\n\n- composer\n- php-json\n- php-mbstring\n\n\n## Eco-system\n\nNeed ``ska`` for other languages? Check the following affiliated projects:\n\n- [ska](https://github.com/barseghyanartur/ska): ``ska`` implementation\n  for Python. This was the first implementation from which current project\n  originated.\n- [skajs](https://github.com/barseghyanartur/skajs): ``ska`` implementation\n  for NodeJS (both CommonJS and ESM are supported, Node \u003e= 14).\n\nGenerated signatures are intercompatible between Python, NodeJS and PHP\nimplementations.\n\n## Installation\n\nLatest stable version from composer registry:\n\n```shell\ncomposer require barseghyanartur/ska\n```\n\n## Usage examples\n\nUsage example are present.\n\n```shell\nphp examples/kitchen_sink.php\n```\n\n### Basic usage\n\n#### Sender side\n\nSigning dictionaries is as simple as follows.\n\n##### Required imports.\n\n```php\nrequire_once(dirname(__FILE__).\"/src/SKA/core.php\");\nuse SKA;\n```\n\n##### Sign data\n\n**Sample usage:**\n\n```php\n$signedData = SKA\\signatureToDict(\"user\", \"your-secret_key\");\nprint_r($signedData);\n```\n\n**Sample output:**\n\n```php\nArray\n(\n    [signature] =\u003e WEwnd40jMusHD6hRZ9WOCR8Zym4=\n    [auth_user] =\u003e user\n    [valid_until] =\u003e 1631795130.0\n    [extra] =\u003e \n)\n```\n\n**Adding of additional data to the signature works in the same way:**\n\n```php\n$signedData = SKA\\signatureToDict(\n    \"user\", \n    \"your-secret_key\", \n    [\n        \"email\" =\u003e \"john.doe@mail.example.com\",\n        \"first_name\" =\u003e \"John\",\n        \"last_name\" =\u003e \"Doe\",\n    ]\n);\nprint_r($signedData);\n```\n\n**Sample output:**\n\n```php\nArray\n(\n    [signature] =\u003e B0sscS+xXWU+NR+9dBCoGFnDtlw=\n    [auth_user] =\u003e user\n    [valid_until] =\u003e 1631797926.0\n    [extra] =\u003e email,first_name,last_name\n    [email] =\u003e john.doe@mail.example.com\n    [first_name] =\u003e John\n    [last_name] =\u003e Doe\n)\n```\n\n**Options and defaults:**\n\nThe `signatureToDict` function accepts an optional `$options` argument.\n\nDefault value for the `validUntil` in the `$options` is 10 minutes from now. If\nyou want it to be different, set `validUntil` in the `$options` of \nthe `signatureToDict` function.\n\nDefault lifetime of a signature is 10 minutes (600 seconds). If you want it\nto be different, set `lifetime` in the `$options` of the `signatureToDict` function.\n\nDefault name of the (GET) param holding the generated signature value\nis `signature`. If you want it to be different, set the `signatureParam`\nin the `$options` of the `signatureToDict` function.\n\nDefault name of the (GET) param holding the `authUser` value is\n`auth_user`. If you want it to be different, set `authUserParam`\nin the `$options` of the `signatureToDict` function.\n\nDefault name of the (GET) param holding the `validUntil` value is\n`valid_until`. If you want it to be different, set the `validUntilParam`\nin the `$options` of the `signatureToDict` function.\n\nDefault name of the (GET) param holding the `extra` value is\n`extra`. If you want it to be different, set the `extraParam`\nin the `$options` of the `signatureToDict` function.\n\n```php\n$signedData = SKA\\signatureToDict(\n    \"user\", \n    \"your-secret_key\", \n    [\n        \"email\" =\u003e \"john.doe@mail.example.com\",\n        \"first_name\" =\u003e \"John\",\n        \"last_name\" =\u003e \"Doe\",\n    ],\n    [\n        \"authUserParam\" =\u003e \"webshop_id\"  \n    ]\n)\nprint_r($signedData);\n```\n\n**Sample output:**\n\n```php\nArray\n(\n    [signature] =\u003e nu0Un+05z/cNOFnLwQnigoW/KmA=\n    [webshop_id] =\u003e user\n    [valid_until] =\u003e 1631799172.0\n    [extra] =\u003e email,first_name,last_name\n    [email] =\u003e john.doe@mail.example.com\n    [first_name] =\u003e John\n    [last_name] =\u003e Doe\n)\n```\n\n#### Recipient side\n\nValidating the signed request data is as simple as follows.\n\n##### Validate signed requests\n\nValidating the signed request data. Note, that `$data` value is expected to\nbe a dictionary; `$request-\u003eGET` is given as an example.\n\n```php\n$validationResult = SKA\\validateSignedRequestData(\n    $request-\u003eGET, // Note, that `$request-\u003eGET` is given as example.\n    \"your-secret_key\"\n);\n```\n\n**Options and defaults:**\n\nSimilarly to `signatureToDict` function, the `validateSignedRequestData`\nalso accepts a number of optional arguments (which have been described above):\n\n- signatureParam\n- authUserParam\n- validUntilParam\n- extraParam\n\nWith some customizations, it would look as follows:\n\n```php\n$validationResult = SKA\\validateSignedRequestData(\n    $request-\u003eGET,\n    \"your-secret_key\",\n    [\n        \"authUserParam\" =\u003e \"webshop_id\"\n    ]\n);\n```\n\n# Testing\n\nSimply type:\n\n```shell\ncomposer test\n```\n\n# Code style\n\nThe `Prettier` is used.\n\n```shell\nnpx prettier --write .\n```\n\n# License\n\nMIT\n\n# Support\n\nFor any issues contact me at the e-mail given in the [Author](#Author) section.\n\n# Author\n\nArtur Barseghyan \u003cartur.barseghyan@gmail.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarseghyanartur%2Fskaphp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarseghyanartur%2Fskaphp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarseghyanartur%2Fskaphp/lists"}