NAME
WWW::Suffit::RSA - The RSA encryption and signing subclass
SYNOPSIS
use WWW::Suffit::RSA;
my $rsa = WWW::Suffit::RSA->new;
$rsa->keygen(2048);
my $private_key = $rsa->private_key;
my $public_key = $rsa->public_key;
my $b64_cipher_text = $rsa->encrypt("test");
my $plain_text = $rsa->decrypt($b64_cipher_text);
my $signature = $rsa->sign("Text", 256) or die $rsa->error;
$rsa->verify("Text", $signature, 256) or die $rsa->error || "Incorrect signature";
DESCRIPTION
The RSA encryption and signing subclass
This module based on Crypt::OpenSSL::RSA
METHODS
WWW::Suffit::RSA inherits all of the properties and methods from Mojo::Base and implements the following new ones.
decrypt
my $plain_text = $rsa->decrypt($b64_cipher_text);
Decrypt a base64 short "string" to plain text
encrypt
my $b64_cipher_text = $rsa->encrypt("test");
Encrypt a short "string" using the public key and returns base64 string
error
$rsa->error($new_error);
my $error = $rsa->error;
Sets/gets the error string
keygen
$rsa->keygen( $key_size );
my $public_key = $rsa->public_key;
my $private_key = $rsa->private_key;
Create a new private/public key pair (the public exponent is 65537). The argument is the key size, default is 2048
private_key
The RSA private key to be used in edcoding an asymmetrically signed data
public_key
The RSA public key to be used in decoding an asymmetrically signed data
sign
my $signature = $rsa->sign($string, $size);
Returns the RSA signature for the given size and string. The "private_key" attribute is used as the private key. The result is not yet base64 encoded. This method is provided mostly for the purposes of subclassing.
verify
my $bool = $rsa->verify($string, $signature, $size);
Returns true if the given RSA size algorithm validates the given string and signature. The "public_key" attribute is used as the public key. This method is provided mostly for the purposes of subclassing.
DEPENDENCIES
HISTORY
See Changes
file
TO DO
See TODO
file
SEE ALSO
Mojolicious, Crypt::OpenSSL::RSA
AUTHOR
Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>
COPYRIGHT
Copyright (C) 1998-2023 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/