Interface for gpg (GnuPG) shell commands
Vajay Attila f0419eee50 Create config.php | 3 years ago | |
---|---|---|
.gitignore | 5 years ago | |
GPGColonParser.php | 5 years ago | |
GPGShell.php | 5 years ago | |
GPGStructure.json | 6 years ago | |
GPGTest.php | 5 years ago | |
Gpgshell_lib.php | 5 years ago | |
LICENSE | 6 years ago | |
README.md | 5 years ago | |
config.php | 3 years ago | |
decrypted.txt | 6 years ago | |
encodable.txt | 6 years ago | |
message.gpg | 6 years ago | |
privatekey.gpg | 6 years ago | |
publickey.gpg | 6 years ago |
Interface for gpg (GnuPG) shell commands Inspired by https://maslosoft.com/blog/2017/09/12/using-gpg-with-php-on-server/ Documentation for ---with-colons directive: https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/DETAILS
GnuPG (https://gnupg.org/)
sudo mkdir -p .gnupg
sudo chown -R www-data:www-data .gnupg
sudo chmod 700 .gnupg
sudo gpg --quick-generate-key --homedir .gnupg test@gpgshell.example
Then type into your browser: http://localhost:8000/GPGTest.php
## Featured GnuPG directives
- --list-keys
- --list-secret-keys
- --export
- --export-secret-key
- --import
- --encrypt
- --decrypt
- --detach-sign
- --verify
- --list-packets
- --import-ownertrust
- --gen-key
## Sample gpg commands
### Internal commands
- Delete keypairs
sudo gpg --homedir .gnupg --delete-secret-key test@gpgshell.example sudo gpg --homedir .gnupg --delete-key test@gpgshell.example
- Edit keys
sudo gpg --local-user www-data --edit-key --homedir .gnupg test@gpgshell.example
### Batch commands
- List public and private keys
sudo gpg --batch --quiet --local-user www-data --list-keys --homedir .gnupg sudo gpg --batch --quiet --local-user www-data --list-secret-keys --homedir .gnupg
- Export keypair
sudo gpg --batch --quiet --local-user www-data --armor --homedir .gnupg --export-secret-key test@gpgshell.example > privatekey.gpg sudo gpg --batch --quiet --local-user www-data --armor --homedir .gnupg --export test@gpgshell.example > publickey.gpg
- Import keypair
sudo gpg --batch --quiet --local-user www-data --armor --homedir .gnupg --import privatekey.gpg sudo gpg --batch --quiet --local-user www-data --armor --homedir .gnupg --import publickey.gpg then interactive command: sudo gpg --local-user www-data --edit-key --homedir .gnupg test@gpgshell.example gpg> trust
- Decrypt
sudo gpg --batch --quiet --local-user www-data --decrypt --homedir .gnupg --output decrypted.txt message.gpg
- Encrypt
sudo gpg --batch --quiet --local-user www-data --armor --encrypt --homedir .gnupg --output message.gpg --recipient test@gpgshell.example encodable.txt
- Detach Sign
gpg --detach-sign --armor --batch --quiet --yes --output ./encodeble.txt.sig --recipient import@test ./encodable.txt
- Verify
gpg --batch --quiet --recipient import@test --verify ./encodeble.txt.sig ./encodable.txt
- List packets
gpg --list-packets --batch --homedir .gnupg test.pgp
## GPGShell library for CodeIgniter
### Load library
$this->load->library('gpgshell_lib');
### Using gpgshell_lib library
$this->gpgshell_lib->encrypt(.......) ```
Add deleteAllKeyByEmail
new Programmable gpg exe name