You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When messages are passed between two systems via a public network, encryption tools must be used to secure the communication channel. The process of encrypting and decrypting a message is complex and prone to errors, but is simplified in this repository by providing the `Message` and `EncryptedMessage` class abstractions.
4
+
When messages are passed between two systems via a public network, encryption tools must be used to secure the communication channel. The process of encrypting and decrypting a message is complex and prone to errors, but is simplified in this repository by providing the `PlainTextMessage` and `EncryptedMessage` class abstractions.
5
5
6
-
Pass your plain text message to the `Message` constructor along with a private key, and you can call `getCipherText()` and `getIv()`. These two strings can be passed to the receiver by any communication mechanism, safe in the knowledge that the contents can not be read without the private key.
6
+
Pass your secret message to the `PlainTextMessage` constructor along with a private key, and you can call `encrypt()` to convert it into an `EncryptedMessage`. An `EncryptedMessage` is represented by a Cipher and IV value via the `getCipherText()` and `getIv()` functions. These two strings can be passed to the receiver by any communication mechanism, safe in the knowledge that the contents can not be read without the private key.
7
7
8
-
On the receiver, construct an`EncryptedMessage` with the incoming ciphertext, and the same private key and IV, and the original message can be read.
8
+
On the receiver, construct another`EncryptedMessage` with the incoming cipher and IV, and the original message can be read using `decrypt()`
9
9
10
-
The `URIAdapter` class can be used to convert from a `Message` to a URI query string, or from a URI to an `EncryptedMessage`.
10
+
The `CipherText` class also exposes a `getUri()` function, for creating a pre-encoded URI. A URI with `cipher` and `iv` querystring parameters can be passed to the `EncryptedUri` class to decrypt back into a `PlainTextMessage`.
11
11
12
12
***
13
13
@@ -32,20 +32,26 @@ The `URIAdapter` class can be used to convert from a `Message` to a URI query st
32
32
`sender.php`:
33
33
34
34
```php
35
-
$message = "Hello, PHP.Gt!";
35
+
use \Gt\Cipher\Message\PlainTextMessage;
36
+
use \Gt\Cipher\Message\EncryptedMessage;
37
+
36
38
$privateKey = "This can be any string, but a long random string is best.";
37
39
38
-
$message = new \Gt\Cipher\Message\PlainTextMessage($message, $privateKey);
39
-
// Redirect to receiver.php, possibly on another server:
40
-
header("Location: " . new \Gt\Cipher\CipherUri($message, "/receiver.php"));
40
+
$message = new PlainTextMessage("Hello, PHP.Gt!");
0 commit comments