paragonie / quill
快速且轻松地将数据写入Chronicle实例的库
v0.7.0
2024-05-08 17:14 UTC
Requires
- php: ^7.1|^8
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^6
- paragonie/certainty: ^2.9
- paragonie/constant_time_encoding: ^2|^3
- paragonie/sapient: ^1
- paragonie/sodium_compat: ^1.21|^2
Requires (Dev)
- phpunit/phpunit: ^7|^8|^9
- vimeo/psalm: ^3|^4
README
Quill 是一个将数据发布到 Chronicle 实例的库。 需要 PHP 7.1 或更高版本。建议使用 PHP 7.2+。
还提供了一个 monolog 处理器。
安装
composer require paragonie/quill
用法
<?php use ParagonIE\ConstantTime\Base64UrlSafe; use ParagonIE\Quill\Quill; use ParagonIE\Sapient\CryptographyKeys\{ SigningSecretKey, SigningPublicKey }; $quill = (new Quill()) ->setChronicleURL('https://chronicle-public-test.paragonie.com/chronicle') ->setServerPublicKey( new SigningPublicKey( Base64UrlSafe::decode('3BK4hOYTWJbLV5QdqS-DFKEYOMKd-G5M9BvfbqG1ICI=') ) ) ->setClientID('**Your Client ID provided by the Chronicle here**') ->setClientSecretKey( new SigningSecretKey('/* Loaded from the filesystem or something. */') ); $quill->write("Important security notice goes here.");
写入数据(未加密)
有两个主要的API方法执行相同的功能,但返回值不同
write(string $input): ResponseInterface
- 返回PSR-7 Response对象,或抛出异常
blindWrite(string $input): bool
- 返回
TRUE
或FALSE
- 返回
写入数据(对称加密)
如果您想使用 共享加密密钥 加密消息
writeEncrypted(string $input, SharedEncryptionKey $key): ResponseInterface
- 返回PSR-7 Response对象,或抛出异常
blindWriteEncrypted(string $input, SharedEncryptionKey $key): bool
- 返回
TRUE
或FALSE
- 返回
写入数据(非对称加密)
如果您想使用 公钥加密 加密消息
writeSealed(string $input, SealingPublicKey $key): ResponseInterface
- 返回PSR-7 Response对象,或抛出异常
blindWriteSealed(string $input, SealingPublicKey $key): bool
- 返回
TRUE
或FALSE
- 返回