-
-
Notifications
You must be signed in to change notification settings - Fork 0
API reference
Greg Bowler edited this page Apr 19, 2026
·
1 revision
This page is a compact reference for Cipher's public API.
For walkthroughs and fuller explanations, use the earlier pages in the guide.
__construct(?string $bytes = null)__toString(): stringgetBytes(): string
__construct(int $byteLength = SODIUM_CRYPTO_BOX_NONCEBYTES)getBytes(): stringwithBytes(string $bytes): self__toString(): string
__construct(string $data, InitVector $iv, Key $key)__toString(): stringgetBytes(): stringgetUri(string|Psr\Http\Message\UriInterface $baseUri = ""): Psr\Http\Message\UriInterface
__construct(string|Psr\Http\Message\UriInterface $uri, string $cipherQueryStringParameter = "cipher", string $initVectorStringParameter = "iv")decryptMessage(Key $key): GT\Cipher\Message\PlainTextMessage
__construct(string $data, ?GT\Cipher\InitVector $iv = null)__toString(): stringgetIv(): GT\Cipher\InitVector
encrypt(GT\Cipher\Key $key): GT\Cipher\CipherText
decrypt(GT\Cipher\Key $key): GT\Cipher\Message\PlainTextMessage
GT\Cipher\CipherException
GT\Cipher\EncryptionFailureExceptionGT\Cipher\MissingQueryStringExceptionGT\Cipher\UriDecryptionFailureException
GT\Cipher\Message\DecryptionFailureException
$message = new GT\Cipher\Message\PlainTextMessage("hello");
$cipherText = $message->encrypt($key);
$received = new GT\Cipher\Message\EncryptedMessage(
(string)$cipherText,
$message->getIv(),
);
$plainText = $received->decrypt($key);$message = new GT\Cipher\Message\PlainTextMessage("hello");
$cipherText = $message->encrypt($key);
$uri = $cipherText->getUri("https://example.com/");
$received = new GT\Cipher\EncryptedUri((string)$uri);
$plainText = $received->decryptMessage($key);- PHP
>= 8.4 ext-sodiumphpgt/http
PHP.GT/Cipher is a separately maintained component of PHP.GT/WebEngine.