NAME
CTK::Crypt - GPG Crypt backend
VERSION
Version 1.01
SYNOPSIS
use CTK::Crypt::GPG;
my $gpg = CTK::Crypt::GPG->new(
-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 );
DESCRIPTION
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"
new
my $gpg = CTK::Crypt::GPG->new(
-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");
- gpgbin
-
GPG program
For example: "/usr/bin/gpg"
Default: gpg from PATH
- gpghome, homedir
-
GPG homedir
For example: "/gpg/homedir"
Default: /tmp/gpgXXXXX
- gpgconf
-
Path to GPG config file (for options storing)
For example: "/gpg/homedir/gpg.conf"
Default: /tmp/gpgXXXXX/gpg.conf
- gpgopts, options
-
GPG default options
For example: ["verbose", "yes"]
Default: ["verbose", "yes"],
- publickey, pubkey, pubring
-
Public key path
For example: "/path/to/public.key"
- privatekey, privkey, privring, seckey, secring
-
Private key path
For example: "/path/to/private.key"
- password, passphrase, passw, pass
-
Private key password
For example: "passphrase"
- recipient, keyid, id, user, keygrip
-
Email, user id, keyid, or keygrip
For example: "anonymous@example.com",
decrypt
$gpg->decrypt(
-infile => "MyDocument.txt.asc",
-outfile=> "MyDocument.txt",
) or die( $gpg->error );
PGP file decrypting
- in, filein, filesrs, infile, src
-
Source file (encrypted file)
- out, fileout, filedst, outfile, dst
-
Target file
encrypt
$gpg->encrypt(
-infile => "MyDocument.txt",
-outfile=> "MyDocument.txt.asc",
-armor => "yes",
) or die( $gpg->error );
PGP file encrypting
- in, filein, filesrs, infile, src
-
Source file
- out, fileout, filedst, outfile, dst
-
Target file (encrypted file)
- armor, ascii
-
Enable armor-mode (as text output): yes, on, 1, enable
For example: "yes"
Default: "no"
error
print $gpg->error;
Returns error string
HISTORY
See Changes
file
DEPENDENCIES
TO DO
See TODO
file
BUGS
* none noted
SEE ALSO
CTK::Util, http://www.gnupg.org, GPG4Win
AUTHOR
Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>
COPYRIGHT
Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved
LICENSE
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/