PHPackages                             vandalorumrex/crypt - 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. vandalorumrex/crypt

ActiveLibrary[Security](/categories/security)

vandalorumrex/crypt
===================

Класс, который шифрует и расшифровывает файлы по алгоритмам, используемым WhatsApp

v1.0.2(10mo ago)10[2 PRs](https://github.com/VandalorumRex/crypt/pulls)MITPHPPHP &gt;=8.1CI passing

Since Aug 28Pushed 7mo agoCompare

[ Source](https://github.com/VandalorumRex/crypt)[ Packagist](https://packagist.org/packages/vandalorumrex/crypt)[ Docs](https://github.com/vandalorumrex/crypt)[ RSS](/packages/vandalorumrex-crypt/feed)WikiDiscussions master Synced 2mo ago

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

Класс, который шифрует и расшифровывает файлы по алгоритмам, используемым WhatsApp
----------------------------------------------------------------------------------

[](#класс-который-шифрует-и-расшифровывает-файлы-по-алгоритмам-используемым-whatsapp)

Тестовые файлы можно найти в папке `samples`:

- `*.original` - оригинальный файл;
- `*.key` - ключ для шифрования (дешифрования) - `mediaKey`;
- `*.encrypted` - зашифрованный файл;
- `*.sidecar` - информация для стриминга.

Шифрование
----------

[](#шифрование)

1. Generate your own `mediaKey`, which needs to be 32 bytes, or use an existing one when available.
2. Expand it to 112 bytes using HKDF with SHA-256 and type-specific application info (see below). Call this value `mediaKeyExpanded`.
3. Split `mediaKeyExpanded` into:
    - `iv`: `mediaKeyExpanded[:16]`
    - `cipherKey`: `mediaKeyExpanded[16:48]`
    - `macKey`: `mediaKeyExpanded[48:80]`
    - `refKey`: `mediaKeyExpanded[80:]` (not used)
4. Encrypt the file with AES-CBC using `cipherKey` and `iv`, pad it and call it `enc`.
5. Sign `iv + enc` with `macKey` using HMAC SHA-256 and store the first 10 bytes of the hash as `mac`.
6. Append `mac` to the `enc` to obtain the result.

Дешифрование
------------

[](#дешифрование)

1. Obtain `mediaKey`.
2. Expand it to 112 bytes using HKDF with SHA-256 and type-specific application info (see below). Call this value `mediaKeyExpanded`.
3. Split `mediaKeyExpanded` into:
    - `iv`: `mediaKeyExpanded[:16]`
    - `cipherKey`: `mediaKeyExpanded[16:48]`
    - `macKey`: `mediaKeyExpanded[48:80]`
    - `refKey`: `mediaKeyExpanded[80:]` (not used)
4. Obtain encrypted media data and split it into:
    - `file`: `mediaData[:-10]`
    - `mac`: `mediaData[-10:]`
5. Validate media data with HMAC by signing `iv + file` with `macKey` using SHA-256. Take in mind that `mac` is truncated to 10 bytes, so you should compare only the first 10 bytes.
6. Decrypt `file` with AES-CBC using `cipherKey` and `iv`, and unpad it to obtain the result.

Установка
---------

[](#установка)

composer require vandalorumrex/crypt

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance60

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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 ~2 days

Total

3

Last Release

303d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0718ee6a9562679d6fa001109fde0c93f163b7cc679d90801b00ba33f2bfc1e6?d=identicon)[VandalorumRex](/maintainers/VandalorumRex)

---

Top Contributors

[![VandalorumRex](https://avatars.githubusercontent.com/u/12428558?v=4)](https://github.com/VandalorumRex "VandalorumRex (30 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vandalorumrex-crypt/health.svg)

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

###  Alternatives

[cakephp/debug_kit

CakePHP Debug Kit

86314.7M171](/packages/cakephp-debug-kit)[bedita/manager

BEdita Manager - official admin webapp for BEdita4 API

131.2k](/packages/bedita-manager)[cakephp/bake

Bake plugin for CakePHP

11212.0M202](/packages/cakephp-bake)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308954.9k25](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1882.3M44](/packages/dereuromark-cakephp-ide-helper)[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

3361.0M51](/packages/dereuromark-cakephp-tools)

PHPackages © 2026

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