ade_4d3/php-crypto-wrapper

Encryption operations wrapper with sodium for PHP

Maintainers

Package info

github.com/Ade-4d3/PhpCryptoWrapper

pkg:composer/ade_4d3/php-crypto-wrapper

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2025-12-20 06:59 UTC

This package is not auto-updated.

Last update: 2026-03-29 07:01:51 UTC


README

This is a wrapper of sodium for simplifyty cryptograpy operations Empaquetado para simplificación de operaciones criptográficas usando Sodium

This is Free Software with MIT License/ Software libre bajo licencia MIT

Aviable:

  • Argon2id
  • AES-256-GCM
  • ChaCha20-Poly1305

Usage

use PhpCryptoWrapper

Argon

use PhpCryptoWrapper\Argon;

Argon::hash($pass);

Argon::verify($text, $hash); // return bool

$salt = Argon::salt();
Argon::derivation($length, $salt, $text); // Derive a password however or with SODIUM_CRYPTO_AEAD_AES256GCM_KEYBYTES 

AES

use PhpCryptoWrapper\AES;

$key = AES::genKey(); // O you can use Argon::derivation with SODIUM_CRYPTO_AEAD_AES256GCM_KEYBYTES
$additional_data = // Any data ...
[$nonce, $ciphertext] = AES::encrypt($plaintext, $additional_data, $key);

$plaintext = AES::decrypt($ciphertext, $additional_data, $nonce, $key)

ChaCha20Poly1320

use PhpCryptoWrapper\ChaCha20Poly1305;

// [
//   "ChaCha20Poly1305",
//   "ChaCha20Poly1305-IETF",
//   "XChaCha20Poly1305",
// ]
$chacha20 = new ChaCha20Poly1305($algo); // By default XChaCha20Poly1305
$key = $chacha20->genKey(); // Key o wiht Argon

$additional_data = "anydata";
[$nonce, $ct] = $chacha20->encrypt("Asupersecret", $additional_data, $key);

echo $chacha20->decrypt($ct, $additional_data, $nonce, $key) . "\n";