-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsodium-lib-uri.php
More file actions
25 lines (19 loc) · 789 Bytes
/
sodium-lib-uri.php
File metadata and controls
25 lines (19 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
use GT\Cipher\EncryptedUri;
use GT\Cipher\Key;
use GT\Cipher\Message\PlainTextMessage;
require("vendor/autoload.php");
$sharedKey = new Key();
$message = new PlainTextMessage("Cipher test!");
echo "Message to send: $message", PHP_EOL;
$cipherText = $message->encrypt($sharedKey);
$uri = $cipherText->getUri("https://cipher-test.g105b.com/");
echo "Key: $sharedKey", PHP_EOL;
echo "URI: $uri", PHP_EOL;
// At this point, the remote code at example.com has access to the encrypted
// message from the URI's query string parameters.
// The following code represents the receiving side of the platform:
$incomingUri = (string)$uri;
$encryptedUri = new EncryptedUri($uri);
$plainTextMessage = $encryptedUri->decryptMessage($sharedKey);
echo "Decrypted: $plainTextMessage", PHP_EOL;