CTK::Crypt - GPG Crypt backend
Version 1.00
use CTK::Crypt::GPG; my $gpg = new CTK::Crypt::GPG( -gpgbin => "/usr/bin/gpg", -gpghome => "/gpg/homedir", -gpgconf => "/gpg/homedir/gpg.conf", -gpgopts => ["verbose", "yes"], -publickey => "/path/to/public.key", -privatekey => "/path/to/private.key", -password => "passphrase", # Key password -recipient => "anonymous@example.com", # Email, user id, keyid, or keygrip ) or die("Can't create crypter"); $gpg->encrypt( -infile => "MyDocument.txt", -outfile=> "MyDocument.txt.asc", -armor => "yes", ) or die( $gpg->error ); $gpg->decrypt( -infile => "MyDocument.txt.asc", -outfile=> "MyDocument.txt", ) or die( $gpg->error );
GPG Crypt backend
See http://www.gnupg.org (GPG4Win - http://gpg4win.org) for details
For start working with this module You need create public and private GPG keys:
gpg --full-gen-key
Example of interaction (test account):
> Anonymous > anonymous@example.com > Password: test < 58E79B320D135DEE < ADF81A296AAC9503A6135F258E79B320D135DEE
For show list of available keys run:
gpg -k gpg -K
For export keys run:
gpg --export -a -o mypublic.key "anonymous@example.com" gpg --export-secret-keys --batch --pinentry-mode loopback --passphrase "test" -a -o myprivate.key "anonymous@example.com"
my $gpg = new CTK::Crypt::GPG( -gpgbin => "/usr/bin/gpg", -gpghome => "/gpg/homedir", -gpgconf => "/gpg/homedir/gpg.conf", -gpgopts => ["verbose", "yes"], -publickey => "/path/to/public.key", -privatekey => "/path/to/private.key", -password => "passphrase", # Key password -recipient => "anonymous@example.com", # Email, user id, keyid, or keygrip ) or die("Can't create crypter");
GPG program
For example: "/usr/bin/gpg"
Default: gpg from PATH
GPG homedir
For example: "/gpg/homedir"
Default: /tmp/gpgXXXXX
Path to GPG config file (for options storing)
For example: "/gpg/homedir/gpg.conf"
Default: /tmp/gpgXXXXX/gpg.conf
GPG default options
For example: ["verbose", "yes"]
Default: ["verbose", "yes"],
Public key path
For example: "/path/to/public.key"
Private key path
For example: "/path/to/private.key"
Private key password
For example: "passphrase"
Email, user id, keyid, or keygrip
For example: "anonymous@example.com",
$gpg->decrypt( -infile => "MyDocument.txt.asc", -outfile=> "MyDocument.txt", ) or die( $gpg->error );
PGP file decrypting
Source file (encrypted file)
Target file
$gpg->encrypt( -infile => "MyDocument.txt", -outfile=> "MyDocument.txt.asc", -armor => "yes", ) or die( $gpg->error );
PGP file encrypting
Source file
Target file (encrypted file)
Enable armor-mode (as text output): yes, on, 1, enable
For example: "yes"
Default: "no"
print $gpg->error;
Returns error string
See Changes file
Changes
CTK::Util, File::Temp
See TODO file
TODO
* none noted
CTK::Util, http://www.gnupg.org, GPG4Win
Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>
Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See LICENSE file and https://dev.perl.org/licenses/
LICENSE
To install CTK, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CTK
CPAN shell
perl -MCPAN -e shell install CTK
For more information on module installation, please visit the detailed CPAN module installation guide.