App-SimpleBackuper
view release on metacpan or search on metacpan
bin/simple-backuper view on Meta::CPAN
! $state{db} or ! @{ $state{db}->{backups} }
or usage(qq|Database already exists and contains |.@{ $state{db}->{backups} }.qq| backups. |
.qq|If you want to rewrite database file with restored one, please delete current database file $options{db}|);
$options{'priv-key'} or usage("Required option --priv-key doesn't specified");
$options{storage} or usage("Required option --storage doesn't specified");
open(my $h, '<', $options{'priv-key'}) or usage(qq|Can't read private key file '$options{"priv-key"}': $!|);
$state{rsa} = Crypt::OpenSSL::RSA->new_private_key( join('', <$h>) );
close($h);
App::SimpleBackuper::RestoreDB(\%options, \%state);
}
# TODO: ÑÑаÑиÑÑика: кол-во бекапов, кол-во бекапов без единого ÑдалÑнного Ñайла, % Ñайлов в каждом бекапе
elsif($command eq 'stats') {
App::SimpleBackuper::_print_table([
['name', 'max files cnt', 'current files cnt', '%'],
map {[
$_->{name},
local/lib/perl5/x86_64-linux-gnu-thread-multi/Crypt/OpenSSL/RSA.pm view on Meta::CPAN
use Crypt::OpenSSL::Random;
use Crypt::OpenSSL::RSA;
# not necessary if we have /dev/random:
Crypt::OpenSSL::Random::random_seed($good_entropy);
Crypt::OpenSSL::RSA->import_random_seed();
$rsa_pub = Crypt::OpenSSL::RSA->new_public_key($key_string);
$ciphertext = $rsa->encrypt($plaintext);
$rsa_priv = Crypt::OpenSSL::RSA->new_private_key($key_string);
$plaintext = $rsa->encrypt($ciphertext);
$rsa = Crypt::OpenSSL::RSA->generate_key(1024); # or
$rsa = Crypt::OpenSSL::RSA->generate_key(1024, $prime);
print "private key is:\n", $rsa->get_private_key_string();
print "public key (in PKCS1 format) is:\n",
$rsa->get_public_key_string();
print "public key (in X509 format) is:\n",
$rsa->get_public_key_x509_string();
$rsa_priv->use_md5_hash(); # insecure. use_sha256_hash or use_sha1_hash are the default
$signature = $rsa_priv->sign($plaintext);
print "Signed correctly\n" if ($rsa->verify($plaintext, $signature));
=head1 DESCRIPTION
local/lib/perl5/x86_64-linux-gnu-thread-multi/Crypt/OpenSSL/RSA.pm view on Meta::CPAN
return $proto->_new_public_key_pkcs1($p_key_string);
}
elsif ( $p_key_string =~ /^-----BEGIN PUBLIC KEY-----/ ) {
return $proto->_new_public_key_x509($p_key_string);
}
else {
croak "unrecognized key format";
}
}
=item new_private_key
Create a new C<Crypt::OpenSSL::RSA> object by loading a private key in
from an string containing the Base64/DER encoding of the PKCS1
representation of the key. The string should include the
C<-----BEGIN...-----> and C<-----END...-----> lines. The padding is set to
PKCS1_OAEP, but can be changed with C<use_xxx_padding>.
An optional parameter can be passed for passphase protected private key:
=over
local/lib/perl5/x86_64-linux-gnu-thread-multi/Crypt/OpenSSL/RSA.pm view on Meta::CPAN
Return the Base64/DER-encoded representation of the "subject
public key", suitable for use in X509 certificates. This string has
header and footer lines:
-----BEGIN PUBLIC KEY------
-----END PUBLIC KEY------
and is the format that is produced by running C<openssl rsa -pubout>.
=item get_private_key_string
Return the Base64/DER-encoded PKCS1 representation of the private
key. This string has
header and footer lines:
-----BEGIN RSA PRIVATE KEY------
-----END RSA PRIVATE KEY------
2 optional parameters can be passed for passphase protected private key
string:
t/Actions.t view on Meta::CPAN
App::SimpleBackuper::Backup(\%options, \%state);
ok -f '/tmp/simple-backuper-test/db';
unlink '/tmp/simple-backuper-test/db';
App::SimpleBackuper::RestoreDB(
{db => '/tmp/simple-backuper-test/db', quiet => 1},
{
rsa => Crypt::OpenSSL::RSA->new_private_key($priv_key),
storage => App::SimpleBackuper::StorageLocal->new('/tmp/simple-backuper-test/storage'),
}
);
{
my $db_file = App::SimpleBackuper::RegularFile->new($options{db}, \%options);
$db_file->read();
$db_file->decompress();
$state{db} = App::SimpleBackuper::DB->new( $db_file->data_ref );
}
( run in 1.003 second using v1.01-cache-2.11-cpan-4d50c553e7e )