-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nguyen Van Nguyen <[email protected]>
- Loading branch information
Showing
3 changed files
with
419 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
<?php declare(strict_types=1); | ||
|
||
require_once dirname(__DIR__) . '/vendor/autoload.php'; | ||
|
||
use OpenPGP\OpenPGP; | ||
|
||
$passphase = 'password'; | ||
|
||
$keyData = <<<EOT | ||
-----BEGIN PGP PRIVATE KEY BLOCK----- | ||
Version: PHP Privacy v2 | ||
Comment: https://github.com/web-of-trust/php-privacy | ||
xcMGBGbzdF4BCAC9oH8ngWlGAdNw1MDM5uSU0TF+/ZT7zEX0bEtstJUICSaoXseMl986lHv6pveh | ||
zRE/xDtKzjKK8EFhZOFtz+ZzH7w8HRT60Mfc2kQ8V/SbzxX2tiDt/FF05jB0B4CwNJahOPt9TTiF | ||
h2IXl00Kbo5qTeqdOm833kGlXhp2TZugh7PFCE0HZ43Dff4jUDryrddblK5C1cYJXupLTDUwxllx | ||
Xri5mtDoOlebW9ioujnUxfdiKpu1JjEI0by3LVRlTldl4kdeUOUKvs9Om6cP4KDlFhAYouAq0A+n | ||
ie+0hN8SgdPZzxYQGCmjScEFsCrc5M7mZDok8Q7JoSzENUasurWRABEBAAH+BwMIr/wCH4yYQ9Tg | ||
JgroodBa+Bf7rmhyu/1miYNjuYDp48HDsmfr0zD+pclIR9sLxsDzN73/4T1GlI7vPztkGZSJAxPv | ||
8AvTEtGpPsqwSIKNS5INzSgewpNeEj/DA6X07TZetNI4gfwVtf9CIoyuNOAYZqytGVtlhKY+X0Or | ||
wDMNpADUqNOU2ecC/M3B7miylycXWBs7Vf0qijSbHskcs75aQJBTlbiX3eleASQ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H5kqqxapXb7dnh1tpZ6Onrpl44nS4XAH | ||
A0nUNG/CwKMEGAEIAFcFAmbzdF4WIQRpS5nh9y+FNiXHSe26DdVbcpXuzwkQug3VW3KV7s8CGwws | ||
FAAAAAAAEwAQc2FsdEB3ZWJvZnRydXN0Lm9yZypqWouZ/Xl5Ps5/DZzCAHQAAEZ2CACF65ocDD0D | ||
mg3UV6PjT0pLjl8Ctr967T7J+x2wyEHIyKNhg0SUeMiuzn0kMEWEkG4v5jCiKkArxq1nQlXW90+l | ||
uiGDvHDUxW7Xkb6yWq633Zdsb1asxK7xYCSWw/A0USjV/qegMBPZz15RBy91kB3FtZvXVZDGigiQ | ||
4YNvTDQ1Kas2Emfl/mL+CG4xG889JjeLEQZykOUT9RPVsBgyTohd/5HqkLAJmmYtoJfmH66bKJ74 | ||
zo5RzqYOI9R7G+Nbjt2gctR6/Y6cMtFSeK00IgEttKIEqmCJPSi3dBuWUJo6b98S9XAP7bNIHhYQ | ||
euvmiy/khrPm2L950YJ3KxHg1hpW | ||
=6IZX | ||
-----END PGP PRIVATE KEY BLOCK----- | ||
EOT; | ||
echo 'Decrypt RSA private key' . PHP_EOL; | ||
$privateKey = OpenPGP::decryptPrivateKey( | ||
$keyData, | ||
$passphase, | ||
); | ||
echo "Key algorithm: {$privateKey->getKeyAlgorithm()->name}" . PHP_EOL; | ||
echo "Key version: {$privateKey->getVersion()}" . PHP_EOL; | ||
echo "Key fingerprint: {$privateKey->getFingerprint(true)}" . PHP_EOL; | ||
echo "Key is decrypted: {$privateKey->isDecrypted()}" . PHP_EOL; | ||
echo "User ID: {$privateKey->getPrimaryUser()->getUserID()}" . PHP_EOL . PHP_EOL; | ||
|
||
$keyData = <<<EOT | ||
-----BEGIN PGP PRIVATE KEY BLOCK----- | ||
Version: PHP Privacy v2 | ||
Comment: https://github.com/web-of-trust/php-privacy | ||
xcBIBGbzdF8TBSuBBAAjBCMEAcNsz/wqmSIz8bFREs6m6wPUIW/tYPX7HHWr6/L7c/sTV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edS8 | ||
NvSOJs2W5TBAuBZKx2LRkx6jLOCGzLGJVLxEF8c0A9FZfxuxNVunJtIlqP1mcikZXdAyMGxqIRCo | ||
ocfATARm83RfEgUrgQQAIwQjBAEv+0kM96zeC0bYkw7mXvflrniOLDtXsmqjjUQ1D4MMBFUmVpb6 | ||
pOl/pzZeViV5B++VMGKtPmtA3QgX3rbHfvmPSAE5WshQmB1+spX934HbQHYjh1eL/z1E5mAKqBZu | ||
96WGcD8FDpwYf2WM8MFMHwPFdjtepe9Fl5dktFg/EByaqgb8yQMACgn+BwMICMbaOHAU3Yvg6Hrg | ||
+5GG/UhVOnFVbZ0FePZ/jvm7bSprf3TbnxMBJr1uYdTZnzOw6UYi2Iq48Fc9UCOMMcPH9GaIEZ5M | ||
WFCIYE0izHeSMvGlMVudDRDEkdiMdktQtNHxWTVdC0cNBIHjsIf0vDpVabDCwDgEGBMKAGcFAmbz | ||
dF8WIQQIg+QtsR1YoYixAg+Jc/V+Mj9P/gkQiXP1fjI/T/4CGww8FAAAAAAAEwAgc2FsdEB3ZWJv | ||
ZnRydXN0Lm9yZ5JjYLFxjL+jyRAoYIqospp2H3FiBGnoFFoKh7wRkMHIAAArSwIHTi0a7VYBFpEt | ||
D3SLGUaoTDR4Rv12TM/+A+i0P/GdgbSc8JzTTkpFOg0PFblkg51e0j1AMzzVge8RZZUz3EGOlRIC | ||
CQGiq1gumpD4tbB09KBn3D15mRkR765cYU8+X4UVskZDJXPXOuKivY9L3Pl3nMi2mh4c+Bj2/DYE | ||
eopUxEIhA6NOyw== | ||
=gvTb | ||
-----END PGP PRIVATE KEY BLOCK----- | ||
EOT; | ||
echo 'Decrypt Ecc private key' . PHP_EOL; | ||
$privateKey = OpenPGP::decryptPrivateKey( | ||
$keyData, | ||
$passphase, | ||
); | ||
echo "Key algorithm: {$privateKey->getKeyAlgorithm()->name}" . PHP_EOL; | ||
echo "Key version: {$privateKey->getVersion()}" . PHP_EOL; | ||
echo "Key fingerprint: {$privateKey->getFingerprint(true)}" . PHP_EOL; | ||
echo "Key is decrypted: {$privateKey->isDecrypted()}" . PHP_EOL; | ||
echo "User ID: {$privateKey->getPrimaryUser()->getUserID()}" . PHP_EOL . PHP_EOL; | ||
|
||
$keyData = <<<EOT | ||
-----BEGIN PGP PRIVATE KEY BLOCK----- | ||
Version: PHP Privacy v2 | ||
Comment: https://github.com/web-of-trust/php-privacy | ||
xX0GZvN0XxsAAAAguZIOKaq+iKLgYkkrCADGSIcYg5agqAfHtNAEJqSxdvr+HQcLAwhQs9XrZ2Gw | ||
veCKQN4W0QoL5H84yIoZ0nNW7PrdvR9GVXDyjKzUU7JguqZW1OzZYw80UK5BEBSHEGTw0CKB7PIv | ||
HmtBy8iR01/1aTCRecK7Bh8bCAAAAFwFAmbzdF8iIQb9fZ7fwNAy9C9KKTDNqP+aaaMHdPX5Uh5k | ||
wJuOROdreQkQ/X2e38DQMvQCGwMDCwcJBCIBAgMFFQgMCg4FFgABAgMCHgsNJwcBCQEHAgkCBwMJ | ||
AwAAAAAUcRCdPUC9J8YyRK3+p3Ee36dKxrKmWbKBcLLy9s/sSDR3xafdxqu1ENhr0Vcl2tLs0eyD | ||
C1bcHki4gUXuc3lGoIDBMSSmMz/AU/Upy2BS418UD80qTmd1eWVuIFZhbiBOZ3V5ZW4gPG5ndXll | ||
bm52MTk4MUBnbWFpbC5jb20+wr4GEBsIAAAAXwUCZvN0XyIhBv19nt/A0DL0L0opMM2o/5ppowd0 | ||
9flSHmTAm45E52t5CRD9fZ7fwNAy9AIbAwMLBwkEIgECAwUVCAwKDgUWAAECAwIeCw0nBwEJAQcC | ||
CQIHAwkDAhkBAAAAAFV/EOiqQlyou1/f5iUhY+FSDt1Dle99AlJZzGU1BFAAui2f2mKyvYI+FWLA | ||
/1fLe1nFpi94+rOwziPWWifzfucA/Kbf5n0yrMTpMvWZBO69XBwLzSxOZ3V5ZW4gVmFuIE5ndXll | ||
biA8bmd1eWVubnZAaXdheXZpZXRuYW0uY29tPsK7BhAbCAAAAFwFAmbzdF8iIQb9fZ7fwNAy9C9K | ||
KTDNqP+aaaMHdPX5Uh5kwJuOROdreQkQ/X2e38DQMvQCGwMDCwcJBCIBAgMFFQgMCg4FFgABAgMC | ||
HgsNJwcBCQEHAgkCBwMJAwAAAABjrBD8BFNyCZCib9WG2AudRg2FfVjrITfF4qgYL9R52jFemWjR | ||
6zVRApoyuqjDKIx5r3/Ix0+TIdIFUmNXxTuedBVNyMToXN5oKnqvEj4y/8h8Dcd9BmbzdF8ZAAAA | ||
IMsfoIIqrBdrlfhLBlZ0eDBVBFaCZU1ewbJg4obrHQo5/h0HCwMIrIzjCtSZdG3g6z3u2i3tYcbG | ||
uWZcqMGCKTHeURIId7JLBjOO8f4m4LM1OX0ZS8dMneBc1c0FlCUMhhrOZ7CvEXHq6KKHBr6Zs1fE | ||
SjPClQYYGwgAAAA2BQJm83RfIiEG/X2e38DQMvQvSikwzaj/mmmjB3T1+VIeZMCbjkTna3kJEP19 | ||
nt/A0DL0AhsMAAAAAHSgEGPYo3PxVglzeiIGIhasF7x5d88PoUYpMW6qpViFkvKzR3zTgS9k/PbG | ||
fxvbr0bOCvlMc0I6SEIkAQNQzrmqzryflnwJ9rF+SlaAqEOYWAsA1R9qfQI5gaCaPrMyyyt/n0iA | ||
dDr6uuhek8xEyQTozlh8 | ||
=7VOh | ||
-----END PGP PRIVATE KEY BLOCK----- | ||
EOT; | ||
echo 'Decrypt Curve25519 private key' . PHP_EOL; | ||
$privateKey = OpenPGP::decryptPrivateKey( | ||
$keyData, | ||
$passphase, | ||
); | ||
echo "Key algorithm: {$privateKey->getKeyAlgorithm()->name}" . PHP_EOL; | ||
echo "Key version: {$privateKey->getVersion()}" . PHP_EOL; | ||
echo "Key fingerprint: {$privateKey->getFingerprint(true)}" . PHP_EOL; | ||
echo "Key is decrypted: {$privateKey->isDecrypted()}" . PHP_EOL; | ||
echo "User ID: {$privateKey->getPrimaryUser()->getUserID()}" . PHP_EOL . PHP_EOL; | ||
|
||
$keyData = <<<EOT | ||
-----BEGIN PGP PRIVATE KEY BLOCK----- | ||
Version: PHP Privacy v2 | ||
Comment: https://github.com/web-of-trust/php-privacy | ||
xa8GZvN0YBwAAAA534/3zVc63Sa9eHXzlaC/ncdqDD3sERDopoOFnBMenmPPuTZtTZT38/xeCdIk | ||
IASKr143GjmU1n6A/h0HCwMIUspY5LdtZ0vgRGMLBfRpTCYK8lz0JPyLCs+iJTv2EG7fY/op/Dyj | ||
8aB7TlqG23ZFuPtyGQx/4sT6ag+1AYsLqFKWmEiCCH9Rlb07RMDrPpBLDg5CSypBHCbuo0OYSSpv | ||
sovt+QEQwsA9Bh8cCgAAAFwFAmbzdGAiIQazjtWaxOZ+X6HXYNkumyI5TDt6OxVaaqm3xmcZPJR+ | ||
GgkQs47VmsTmfl8CGwMDCwcJBCIBAgMFFQgMCg4FFgABAgMCHgsNJwcBCQEHAgkCBwMJAwAAAADQ | ||
diDi6XJvWFdH0RuwNYKjfK2jx0mB9gsz/ZJ/GkTEnNl7OMQEjwuwRG7nJdWOWCJ5fhVYsUAtc0kz | ||
zo2g6Km88liWSDkX5ZJ94XtkCtgNVrVbDfxFEeMEF5FaAKToOotzEDaXHxsbi/83RPJWpGe7IabU | ||
VXzZEFeUfsRO3QltkxgknYEFCfpEKlC/yZHOV22foS89AM0qTmd1eWVuIFZhbiBOZ3V5ZW4gPG5n | ||
dXllbm52MTk4MUBnbWFpbC5jb20+wsBABhAcCgAAAF8FAmbzdGAiIQazjtWaxOZ+X6HXYNkumyI5 | ||
TDt6OxVaaqm3xmcZPJR+GgkQs47VmsTmfl8CGwMDCwcJBCIBAgMFFQgMCg4FFgABAgMCHgsNJwcB | ||
CQEHAgkCBwMJAwIZAQAAAABihCBfWkWwXJbc++yBhzjk8Ks39znCXNVSfiZ7BuPXGr8+Q9WMDpe6 | ||
NgC4x/Ar6HiQp6nCl7LjIjqriYHijiOa3J4EJIog7D+llhxZhCBKqv3aSPgWARbLn+fngOgGW4hx | ||
yVpdPRx7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X+wOo4jw6fvZTHW | ||
=XEBL | ||
-----END PGP PRIVATE KEY BLOCK----- | ||
EOT; | ||
echo 'Decrypt Curve448 private key' . PHP_EOL; | ||
$privateKey = OpenPGP::decryptPrivateKey( | ||
$keyData, | ||
$passphase, | ||
); | ||
echo "Key algorithm: {$privateKey->getKeyAlgorithm()->name}" . PHP_EOL; | ||
echo "Key version: {$privateKey->getVersion()}" . PHP_EOL; | ||
echo "Key fingerprint: {$privateKey->getFingerprint(true)}" . PHP_EOL; | ||
echo "Key is decrypted: {$privateKey->isDecrypted()}" . PHP_EOL; | ||
echo "User ID: {$privateKey->getPrimaryUser()->getUserID()}" . PHP_EOL . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php declare(strict_types=1); | ||
|
||
require_once dirname(__DIR__) . '/vendor/autoload.php'; | ||
|
||
use OpenPGP\OpenPGP; | ||
use OpenPGP\Enum\KeyType; | ||
|
||
$userIDs = [ | ||
'Nguyen Van Nguyen <[email protected]>', | ||
'Nguyen Van Nguyen <[email protected]>', | ||
]; | ||
$passphase = 'password'; | ||
|
||
echo 'Generate RSA private key' . PHP_EOL; | ||
$privateKey = OpenPGP::generateKey( | ||
$userIDs, | ||
$passphase, | ||
KeyType::Rsa, | ||
); | ||
echo $privateKey->armor() . PHP_EOL; | ||
|
||
echo 'Generate Ecc private key' . PHP_EOL; | ||
$privateKey = OpenPGP::generateKey( | ||
$userIDs, | ||
$passphase, | ||
KeyType::Ecc, | ||
); | ||
echo $privateKey->armor() . PHP_EOL; | ||
|
||
echo 'Generate Curve25519 private key' . PHP_EOL; | ||
$privateKey = OpenPGP::generateKey( | ||
$userIDs, | ||
$passphase, | ||
KeyType::Curve25519, | ||
); | ||
echo $privateKey->armor() . PHP_EOL; | ||
|
||
echo 'Generate Curve448 private key' . PHP_EOL; | ||
$privateKey = OpenPGP::generateKey( | ||
$userIDs, | ||
$passphase, | ||
KeyType::Curve448, | ||
); | ||
echo $privateKey->armor() . PHP_EOL; |
Oops, something went wrong.