App-GroupSecret

 view release on metacpan or  search on metacpan

lib/App/GroupSecret/Crypt.pm  view on Meta::CPAN

        close $temp;
        $filepath = $temp->filename;
    }

    my @cmd = ($OPENSSL, qw{aes-256-cbc -pass stdin -md sha256 -in}, $filepath);
    push @cmd, ('-out', $outfile) if $outfile;

    my ($in, $out);
    my $pid = open2($out, $in, @cmd);

    print $in $secret;
    close($in);

    waitpid($pid, 0);
    my $status = $?;

    my $exit_code = $status >> 8;
    _croak 'Failed to encrypt plaintext' if $exit_code != 0;

    return do { local $/; <$out> };
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::GroupSecret::Crypt - Collection of crypto-related subroutines

=head1 VERSION

version 0.304

=head1 FUNCTIONS

=head2 generate_secure_random_bytes

    $bytes = generate_secure_random_bytes($num_bytes);

Get a certain number of secure random bytes.

=head2 read_openssh_public_key

    $pem_public_key = read_openssh_public_key($public_key_filepath);

Read a RFC4716 (SSH2) public key from a file, converting it to PKCS8 (PEM).

=head2 read_openssh_key_fingerprint

    $fingerprint = read_openssh_key_fingerprint($filepath);

Get the fingerprint of an OpenSSH private or public key.

=head2 decrypt_rsa

    $plaintext = decrypt_rsa($ciphertext_filepath, $private_key_filepath);
    $plaintext = decrypt_rsa(\$ciphertext, $private_key_filepath);
    decrypt_rsa($ciphertext_filepath, $private_key_filepath, $plaintext_filepath);
    decrypt_rsa(\$ciphertext, $private_key_filepath, $plaintext_filepath);

Do RSA decryption. Turn ciphertext into plaintext.

=head2 encrypt_rsa

    $ciphertext = decrypt_rsa($plaintext_filepath, $public_key_filepath);
    $ciphertext = decrypt_rsa(\$plaintext, $public_key_filepath);
    decrypt_rsa($plaintext_filepath, $public_key_filepath, $ciphertext_filepath);
    decrypt_rsa(\$plaintext, $public_key_filepath, $ciphertext_filepath);

Do RSA encryption. Turn plaintext into ciphertext.

=head2 decrypt_aes_256_cbc

    $plaintext = decrypt_aes_256_cbc($ciphertext_filepath, $secret);
    $plaintext = decrypt_aes_256_cbc(\$ciphertext, $secret);
    decrypt_aes_256_cbc($ciphertext_filepath, $secret, $plaintext_filepath);
    decrypt_aes_256_cbc(\$ciphertext, $secret, $plaintext_filepath);

Do symmetric decryption. Turn ciphertext into plaintext.

=head2 encrypt_aes_256_cbc

    $ciphertext = encrypt_aes_256_cbc($plaintext_filepath, $secret);
    $ciphertext = encrypt_aes_256_cbc(\$plaintext, $secret);
    encrypt_aes_256_cbc($plaintext_filepath, $secret, $ciphertext_filepath);
    encrypt_aes_256_cbc(\$plaintext, $secret, $ciphertext_filepath);

Do symmetric encryption. Turn plaintext into ciphertext.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website
L<https://github.com/chazmcgarvey/groupsecret/issues>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.

=head1 AUTHOR

Charles McGarvey <chazmcgarvey@brokenzipper.com>

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2017 by Charles McGarvey.

This is free software, licensed under:

  The MIT (X11) License

=cut

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.498 second using v1.00-cache-2.02-grep-82fe00e-cpan-b63e86051f13 )