nuxed/crypto

Nuxed Crypto

维护者

详细信息

github.com/nuxed/crypto

源代码

问题

安装次数: 343

依赖项: 2

建议者: 0

安全性: 0

星星: 3

关注者: 3

分支: 4

开放问题: 0

语言:Hack

v2.0.0 2020-11-15 16:18 UTC

This package is auto-updated.

Last update: 2024-09-22 07:51:50 UTC


README

Coding standards status Static analysis status Unit tests status Total Downloads Latest Stable Version License

Nuxed Crypto

Nuxed Crypto 组件提供了一种高级的加密接口,它依赖于libsodium来完成所有底层的加密操作。

灵感来源于Halite

重要

尽管这个库是经过仔细开发的,但它尚未经过安全专家的审查,我们始终有可能忽略了某些东西。在考虑在生产环境中部署之前,请让您的信任黑客检查其实施错误和漏洞。

安装

此软件包可以使用Composer安装。

$ composer require nuxed/crypto

示例

use namespace Nuxed\{Crypto, Filesystem};
use namespace Nuxed\Crypto\Symmetric;

<<__EntryPoint>>
async function main(): Awaitable<void> {
  // generate a key :
  $key = Symmetric\Encryption\Key::generate();
  
  // or load a stored encryption key :
  $file = new Filesystem\File('/path/to/encryption.key');
  $key = $key = Symmetric\Encryption\Key::import(
    new Crypto\HiddenString(await $file->read())
  );

  $message = new Crypto\HiddenString('Hello, World!');
  $ciphertext = Symmetric\Encryption\encrypt($message, $key);
  $plaintext = Symmetric\Encryption\decrypt($ciphertext, $key);

  print $plaintext->toString(); // Hello, World!
}

安全性

有关在 Nuxed 中报告安全漏洞的信息,请参阅SECURITY.md

许可证

Nuxed 是在 MIT 许可下授权的开源软件。