ade_4d3/php-crypto-wrapper
最新稳定版本:v1.1.0
Composer 安装命令:
composer require ade_4d3/php-crypto-wrapper
包简介
Encryption operations wrapper with sodium for PHP
关键字:
README 文档
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";
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-20