ssitu / sod

加密实用工具;两种风味:Sodium(推荐),或Sugar。

v1.0.0 2021-06-22 19:20 UTC

This package is auto-updated.

Last update: 2024-09-22 19:01:16 UTC


README

加密实用工具;两种风味:Sodium(推荐),或Sugar。

入门

$ composer require ssitu/sod

如何使用

use SSITU\Sod\Sod;

require_once '/path/to/vendor/autoload.php';

// Sod config:
$sodConfig["cryptKey"] = '703af4dd03ebe11e35167157a8a697d8a2cb545a907a38289f8a7ba19432a342';
$sodConfig["flavour"] = "Sugar"; # prefer "Sodium" if installed

// Sod init:
$Sod = new Sod($sodConfig);
// or:
# $Sod->setCryptKey(string $key);
# $Sod->setFlavour(string $flavour);

// For a quick check:
$Sod->hasCryptKey();

// To test if Sodium is installed:
var_dump($Sod->isLibSodiumOn());

// Encrypt:
$Sod->encrypt(string $message);

// Decrypt:
$Sod->decrypt(string $message);

// If something went wrong:
$Sod->getLogs();

贡献

当然可以!您可以查看 CONTRIBUTING

许可证

本项目受MIT许可证保护;有关详细信息,请参阅LICENSE