Skip to content

Commit

Permalink
Merge pull request #76 from meitar/docs
Browse files Browse the repository at this point in the history
Provide more guidance for understanding the examples.
  • Loading branch information
singpolyma authored Mar 29, 2019
2 parents fb671e1 + f8e0e99 commit 5e6a097
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
language: php
php:
- 7.0
Expand Down Expand Up @@ -48,4 +49,4 @@ matrix:
- env: PHPSECLIB="2.0.6"
fast_finish: true

before_script: 'sed -i "s/\"phpseclib\/phpseclib\": \"[^\"]*/\"phpseclib\/phpseclib\": \"$PHPSECLIB/" composer.json && composer install --prefer-source --dev'
before_script: 'sed -i "s/\"phpseclib\/phpseclib\": \"[^\"]*/\"phpseclib\/phpseclib\": \"$PHPSECLIB/" composer.json && composer install --prefer-source'
22 changes: 22 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
OpenPGP.php Examples
====================

The scripts in this folder show how to use this library to perform various tasks
such as [generating a new key](keygen.php), [signing a message](sign.php), and
[verifying a message](verify.php) that has been signed.

To use these examples, make sure [`phpseclib`](http://phpseclib.sourceforge.net/) is available. You can install it
using [Composer](https://getcomposer.org/):

```sh
git clone https://github.com/singpolyma/openpgp-php.git # Clone the repository.
cd openpgp-php
composer install # Use Composer to install the requirements.
```

Once Composer has installed the requirements, run the examples using PHP:

```sh
# Generate a new OpenPGP key; see the `keygen.php` file for parameters.
php ./examples/keygen.php > mykey.gpg
```
3 changes: 1 addition & 2 deletions examples/clearsign.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

@include_once dirname(__FILE__).'/../vendor/autoload.php';
require_once dirname(__FILE__).'/../lib/openpgp.php';
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';

Expand Down Expand Up @@ -27,5 +28,3 @@
// trailing whitespace to lines.
echo preg_replace("/^-/", "- -", $packets[0]->data)."\n";
echo OpenPGP::enarmor($packets[1][0]->to_bytes(), "PGP SIGNATURE");

?>
1 change: 1 addition & 0 deletions examples/deASCIIdeCrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// USAGE: php examples/deASCIIdeCrypt.php secretkey.asc password message.asc
// This will fail if the algo on key or message is not 3DES or AES

@include_once dirname(__FILE__).'/../vendor/autoload.php';
require_once dirname(__FILE__).'/../lib/openpgp.php';
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
require_once dirname(__FILE__).'/../lib/openpgp_crypt_symmetric.php';
Expand Down
1 change: 1 addition & 0 deletions examples/encryptDecrypt.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

@include_once dirname(__FILE__).'/../vendor/autoload.php';
require_once dirname(__FILE__).'/../lib/openpgp.php';
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
require_once dirname(__FILE__).'/../lib/openpgp_crypt_symmetric.php';
Expand Down
1 change: 1 addition & 0 deletions examples/keygen.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

@include_once dirname(__FILE__).'/../vendor/autoload.php';
require_once dirname(__FILE__).'/../lib/openpgp.php';
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';

Expand Down
3 changes: 1 addition & 2 deletions examples/sign.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

@include_once dirname(__FILE__).'/../vendor/autoload.php';
require_once dirname(__FILE__).'/../lib/openpgp.php';
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';

Expand All @@ -18,5 +19,3 @@

/* Output the raw message bytes to STDOUT */
echo $m->to_bytes();

?>
3 changes: 1 addition & 2 deletions examples/verify.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

@include_once dirname(__FILE__).'/../vendor/autoload.php';
require_once dirname(__FILE__).'/../lib/openpgp.php';
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';

Expand All @@ -14,5 +15,3 @@

/* Dump verification information to STDOUT */
var_dump($verify->verify($m));

?>

0 comments on commit 5e6a097

Please sign in to comment.