vandalorumrex / crypt
Класс, который шифрует и расшифровывает файлы по алгоритмам, используемым WhatsApp
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 2
pkg:composer/vandalorumrex/crypt
Requires
- php: >=8.1
- cakephp/cakephp: 5.2.*
- cakephp/migrations: ^4.0.0
- cakephp/plugin-installer: ^2.0
Requires (Dev)
- cakephp/bake: ^3.0.0
- cakephp/cakephp-codesniffer: ^5.0
- cakephp/debug_kit: ^5.0.0
- josegonzalez/dotenv: ^4.0
- phpunit/phpunit: ^10.5.5 || ^11.1.3 || ^12.1
This package is auto-updated.
Last update: 2025-11-24 17:55:25 UTC
README
Тестовые файлы можно найти в папке samples:
*.original- оригинальный файл;*.key- ключ для шифрования (дешифрования) -mediaKey;*.encrypted- зашифрованный файл;*.sidecar- информация для стриминга.
Шифрование
- Generate your own
mediaKey, which needs to be 32 bytes, or use an existing one when available. - Expand it to 112 bytes using HKDF with SHA-256 and type-specific application info (see below). Call this value
mediaKeyExpanded. - Split
mediaKeyExpandedinto:iv:mediaKeyExpanded[:16]cipherKey:mediaKeyExpanded[16:48]macKey:mediaKeyExpanded[48:80]refKey:mediaKeyExpanded[80:](not used)
- Encrypt the file with AES-CBC using
cipherKeyandiv, pad it and call itenc. - Sign
iv + encwithmacKeyusing HMAC SHA-256 and store the first 10 bytes of the hash asmac. - Append
macto theencto obtain the result.
Дешифрование
- Obtain
mediaKey. - Expand it to 112 bytes using HKDF with SHA-256 and type-specific application info (see below). Call this value
mediaKeyExpanded. - Split
mediaKeyExpandedinto:iv:mediaKeyExpanded[:16]cipherKey:mediaKeyExpanded[16:48]macKey:mediaKeyExpanded[48:80]refKey:mediaKeyExpanded[80:](not used)
- Obtain encrypted media data and split it into:
file:mediaData[:-10]mac:mediaData[-10:]
- Validate media data with HMAC by signing
iv + filewithmacKeyusing SHA-256. Take in mind thatmacis truncated to 10 bytes, so you should compare only the first 10 bytes. - Decrypt
filewith AES-CBC usingcipherKeyandiv, and unpad it to obtain the result.
Установка
composer require vandalorumrex/crypt