paragonie/quill

快速且轻松地将数据写入Chronicle实例的库

v0.7.0 2024-05-08 17:14 UTC

This package is auto-updated.

Last update: 2024-09-08 18:11:00 UTC


README

Build Status Latest Stable Version Latest Unstable Version License Downloads

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
    • 返回 TRUEFALSE

写入数据(对称加密)

如果您想使用 共享加密密钥 加密消息

  • writeEncrypted(string $input, SharedEncryptionKey $key): ResponseInterface
    • 返回PSR-7 Response对象,或抛出异常
  • blindWriteEncrypted(string $input, SharedEncryptionKey $key): bool
    • 返回 TRUEFALSE

写入数据(非对称加密)

如果您想使用 公钥加密 加密消息

  • writeSealed(string $input, SealingPublicKey $key): ResponseInterface
    • 返回PSR-7 Response对象,或抛出异常
  • blindWriteSealed(string $input, SealingPublicKey $key): bool
    • 返回 TRUEFALSE