-
-
Notifications
You must be signed in to change notification settings - Fork 0
Examples
Greg Bowler edited this page Apr 19, 2026
·
1 revision
The example/ directory is the quickest way to see the main workflows without building a larger application around them first.
Run an example from the repository root:
php example/01-encrypt-decrypt-message.php-
example/01-encrypt-decrypt-message.php
Basic message encryption and decryption using
PlainTextMessageandEncryptedMessage. -
example/02-encrypt-message-in-uri.php
Embedding encrypted content into a URI and reading it back with
EncryptedUri. - example/03-share-key-between-processes.php Reconstructing the same shared key from a base64 string on the receiving side.
There are also a few small scripts in the repository root which show the lower-level building blocks:
- sodium.php: a direct libsodium demonstration with Cipher's exception types
- sodium-lib.php: message encryption and decryption using the library API
- sodium-lib-uri.php: URI-based encryption and decryption using the library API
Those scripts are useful when reading through the repository history or comparing the raw sodium calls with the higher-level abstractions.
The examples are especially helpful when we want to:
- verify the expected string forms of keys, IVs, and cipher text
- see the sender and receiver flow side by side
- test the package quickly in a local shell
If you want the class and method list in one place, finish with API reference.
PHP.GT/Cipher is a separately maintained component of PHP.GT/WebEngine.