Merge pull request #76 from meitar/docs
Provide more guidance for understanding the examples.
This commit is contained in:
commit
5e6a097677
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
language: php
|
language: php
|
||||||
php:
|
php:
|
||||||
- 7.0
|
- 7.0
|
||||||
@ -48,4 +49,4 @@ matrix:
|
|||||||
- env: PHPSECLIB="2.0.6"
|
- env: PHPSECLIB="2.0.6"
|
||||||
fast_finish: true
|
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
examples/README.md
Normal file
22
examples/README.md
Normal file
@ -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
|
||||||
|
```
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
@include_once dirname(__FILE__).'/../vendor/autoload.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||||
|
|
||||||
@ -27,5 +28,3 @@ echo "-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA256\n\n";
|
|||||||
// trailing whitespace to lines.
|
// trailing whitespace to lines.
|
||||||
echo preg_replace("/^-/", "- -", $packets[0]->data)."\n";
|
echo preg_replace("/^-/", "- -", $packets[0]->data)."\n";
|
||||||
echo OpenPGP::enarmor($packets[1][0]->to_bytes(), "PGP SIGNATURE");
|
echo OpenPGP::enarmor($packets[1][0]->to_bytes(), "PGP SIGNATURE");
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// USAGE: php examples/deASCIIdeCrypt.php secretkey.asc password message.asc
|
// 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
|
// 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.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_symmetric.php';
|
require_once dirname(__FILE__).'/../lib/openpgp_crypt_symmetric.php';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
@include_once dirname(__FILE__).'/../vendor/autoload.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_symmetric.php';
|
require_once dirname(__FILE__).'/../lib/openpgp_crypt_symmetric.php';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
@include_once dirname(__FILE__).'/../vendor/autoload.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
@include_once dirname(__FILE__).'/../vendor/autoload.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||||
|
|
||||||
@ -18,5 +19,3 @@ $m = $sign->sign($data);
|
|||||||
|
|
||||||
/* Output the raw message bytes to STDOUT */
|
/* Output the raw message bytes to STDOUT */
|
||||||
echo $m->to_bytes();
|
echo $m->to_bytes();
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
@include_once dirname(__FILE__).'/../vendor/autoload.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||||
|
|
||||||
@ -14,5 +15,3 @@ $verify = new OpenPGP_Crypt_RSA($wkey);
|
|||||||
|
|
||||||
/* Dump verification information to STDOUT */
|
/* Dump verification information to STDOUT */
|
||||||
var_dump($verify->verify($m));
|
var_dump($verify->verify($m));
|
||||||
|
|
||||||
?>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user