PHPackages                             barseghyanartur/ska - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. barseghyanartur/ska

ActiveLibrary[Security](/categories/security)

barseghyanartur/ska
===================

Sign data using symmetric-key algorithm encryption. Validate signed data and identify possible validation errors. Uses sha-(1, 224, 256, 385 and 512)/hmac for signature encryption. Custom hash algorithms are allowed. Useful shortcut functions for signing (and validating) dictionaries and URLs.

0.1.8(4y ago)0319MITPHPPHP ^7.2 || ~8.0.0CI passing

Since Sep 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/barseghyanartur/skaphp)[ Packagist](https://packagist.org/packages/barseghyanartur/ska)[ Docs](https://github.com/barseghyanartur/skaphp)[ RSS](/packages/barseghyanartur-ska/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (7)Versions (10)Used By (0)

ska
===

[](#ska)

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 (associative arrays).

[![Packagist version](https://camo.githubusercontent.com/3b61aeb6e95332f853545561e7f3184aa014579a662ecee5e1db330774d87d0e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6261727365676879616e61727475722f736b612e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465267374796c653d666c61742d737175617265)](https://packagist.org/packages/barseghyanartur/ska)[![Supported PHP versions](https://camo.githubusercontent.com/9c1be84f718eed095820a4727a310ed67d187db743381346d2deb373ca55770a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6261727365676879616e61727475722f736b612e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465267374796c653d666c61742d737175617265)](https://packagist.org/packages/barseghyanartur/ska)[![Build Status](https://github.com/barseghyanartur/skaphp/actions/workflows/tests.yml/badge.svg)](https://github.com/barseghyanartur/skaphp/actions)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/barseghyanartur/skaphp/#License)

Key concepts
------------

[](#key-concepts)

Hosts, that communicate with each other, share the Secret Key, which is used to sign data (requests). Secret key is never sent around.

One of the cases is signing of HTTP requests. Each (HTTP) request is signed on the sender side using the shared Secret Key and as an outcome produces the triple (`signature`, `auth_user`, `valid_until`) which are used to sign the requests.

- `signature` (`string`): Signature generated.
- `auth_user` (`string`): User making the request. Can be anything.
- `valid_until` (`float` or `string`): Signature expiration time (Unix timestamp).

On the recipient side, (HTTP request) data is validated using the shared Secret Key. It's being checked whether signature is valid and not expired.

```
    ┌─────────────┐           Data              ┌─────────────┐
    │   Host 1    ├────────────────────────────>│   Host 2    │
    │ ─────────── │                             │ ─────────── │
    │ secret key  │                             │ secret key  │
    │ 'my-secret' │ WEwnd40jMusHD6hRZ9WOCR8Zym4=
    [auth_user] => user
    [valid_until] => 1631795130.0
    [extra] =>
)
```

**Adding of additional data to the signature works in the same way:**

```
$signedData = SKA\signatureToDict(
    "user",
    "your-secret_key",
    [
        "email" => "john.doe@mail.example.com",
        "first_name" => "John",
        "last_name" => "Doe",
    ]
);
print_r($signedData);
```

**Sample output:**

```
Array
(
    [signature] => B0sscS+xXWU+NR+9dBCoGFnDtlw=
    [auth_user] => user
    [valid_until] => 1631797926.0
    [extra] => email,first_name,last_name
    [email] => john.doe@mail.example.com
    [first_name] => John
    [last_name] => Doe
)
```

**Options and defaults:**

The `signatureToDict` function accepts an optional `$options` argument.

Default value for the `validUntil` in the `$options` is 10 minutes from now. If you want it to be different, set `validUntil` in the `$options` of the `signatureToDict` function.

Default lifetime of a signature is 10 minutes (600 seconds). If you want it to be different, set `lifetime` in the `$options` of the `signatureToDict` function.

Default name of the (GET) param holding the generated signature value is `signature`. If you want it to be different, set the `signatureParam`in the `$options` of the `signatureToDict` function.

Default name of the (GET) param holding the `authUser` value is `auth_user`. If you want it to be different, set `authUserParam`in the `$options` of the `signatureToDict` function.

Default name of the (GET) param holding the `validUntil` value is `valid_until`. If you want it to be different, set the `validUntilParam`in the `$options` of the `signatureToDict` function.

Default name of the (GET) param holding the `extra` value is `extra`. If you want it to be different, set the `extraParam`in the `$options` of the `signatureToDict` function.

```
$signedData = SKA\signatureToDict(
    "user",
    "your-secret_key",
    [
        "email" => "john.doe@mail.example.com",
        "first_name" => "John",
        "last_name" => "Doe",
    ],
    [
        "authUserParam" => "webshop_id"
    ]
)
print_r($signedData);
```

**Sample output:**

```
Array
(
    [signature] => nu0Un+05z/cNOFnLwQnigoW/KmA=
    [webshop_id] => user
    [valid_until] => 1631799172.0
    [extra] => email,first_name,last_name
    [email] => john.doe@mail.example.com
    [first_name] => John
    [last_name] => Doe
)
```

#### Recipient side

[](#recipient-side)

Validating the signed request data is as simple as follows.

##### Validate signed requests

[](#validate-signed-requests)

Validating the signed request data. Note, that `$data` value is expected to be a dictionary; `$request->GET` is given as an example.

```
$validationResult = SKA\validateSignedRequestData(
    $request->GET, // Note, that `$request->GET` is given as example.
    "your-secret_key"
);
```

**Options and defaults:**

Similarly to `signatureToDict` function, the `validateSignedRequestData`also accepts a number of optional arguments (which have been described above):

- signatureParam
- authUserParam
- validUntilParam
- extraParam

With some customizations, it would look as follows:

```
$validationResult = SKA\validateSignedRequestData(
    $request->GET,
    "your-secret_key",
    [
        "authUserParam" => "webshop_id"
    ]
);
```

Testing
=======

[](#testing)

Simply type:

```
composer test
```

Code style
==========

[](#code-style)

The `Prettier` is used.

```
npx prettier --write .
```

License
=======

[](#license)

MIT

Support
=======

[](#support)

For any issues contact me at the e-mail given in the [Author](#Author) section.

Author
======

[](#author)

Artur Barseghyan

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Recently: every ~14 days

Total

9

Last Release

1635d ago

PHP version history (3 changes)0.1.0PHP ^7.4 || ~8.0.0

0.1.4PHP ^7.3 || ~8.0.0

0.1.7PHP ^7.2 || ~8.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4835433273fb585d739b1101024f43019a7abd70c70efe625dd3101d7ed42d4a?d=identicon)[barseghyanartur](/maintainers/barseghyanartur)

---

Top Contributors

[![barseghyanartur](https://avatars.githubusercontent.com/u/4925587?v=4)](https://github.com/barseghyanartur "barseghyanartur (24 commits)")

---

Tags

data-encryptiondata-hashencryptionphp-librarysecuritysecurityencryptiondata encryptiondata-hash

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/barseghyanartur-ska/health.svg)

```
[![Health](https://phpackages.com/badges/barseghyanartur-ska/health.svg)](https://phpackages.com/packages/barseghyanartur-ska)
```

###  Alternatives

[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k434.8M1.3k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[ass/xmlsecurity

The XmlSecurity library is written in PHP for working with XML Encryption and Signatures

955.6M30](/packages/ass-xmlsecurity)[nzo/url-encryptor-bundle

The NzoUrlEncryptorBundle is a Symfony Bundle used to Encrypt and Decrypt data and variables in the Web application or passed through URL

961.0M2](/packages/nzo-url-encryptor-bundle)[tilleuls/url-signer-bundle

Create and validate signed URLs with a limited lifetime in Symfony

81340.1k](/packages/tilleuls-url-signer-bundle)[ercsctt/laravel-file-encryption

Secure file encryption and decryption for Laravel applications

642.6k](/packages/ercsctt-laravel-file-encryption)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
