Solstice::Encryption - Solstice's standard two-way encryption library.


Solstice documentation  | view source Contained in the Solstice distribution.

Index


NAME

Top

Solstice::Encryption - Solstice's standard two-way encryption library.

SYNOPSIS

Top

  use Solstice::Encryption;

  my $encrypter = Solstice::Encryption->new;

  my $ciphertext = $encrypter->encrypt($string);

  my $string = $encrypter->decrypt($ciphertext);

DESCRIPTION

Top

Will encrypt/decrypt a string using the Rijndael algorithm (aes).

Export

No symbols exported.

Methods

new()

Constructor. Returns an encrypter object.

encrypt(plain_text_string)

Returns the encrypted version of the plain_text_string in URL safe text.

encryptHex(plain_text_string) Returns the encrypted version of the plain_text_string escaped as hex. =cut

sub encryptHex { my $self = shift; my $pt = shift; return unpack "H*", $self->_encrypt($pt); }

_encrypt() =cut

sub _encrypt { my $self = shift; my $pt = shift; # text to encode

    # require a parameter
    return undef unless (defined $pt && $pt);

    # make sure that our data is a multiple of DIVISOR bytes.
    my $length = length(Unicode::String->new($pt)->as_string());
    if ($length % DIVISOR != 0) {
        $pt = ' ' x (DIVISOR - ($length % DIVISOR)) . $pt;
    }
    return $self->_getCipher()->encrypt($pt);
}

decrypt(encrypted_string)

Returns the decrypted version of the encrypted_string

decryptHex(encrypted_string) Returns the decrypted version of the encrypted string. =cut

sub decryptHex { my $self = shift; my $cipher = shift; return undef unless (defined $cipher && $cipher); return $self->_decrypt(pack "H*", $cipher); }

_decrypt() =cut

sub _decrypt { my $self = shift; my $et = shift; my $padded; eval{ $padded = $self->_getCipher()->decrypt($et); };

    $padded =~ s/^[ ]*//;
    return $padded;
}

Private Methods

_setCipher($cipher)
_getCipher()

Modules Used

Crypt::Rijndael, MIME::Base64, URI::Escape.

AUTHOR

Top

Catalyst Group, <catalyst@u.washington.edu>

VERSION

Top

$Revision: 3364 $

COPYRIGHT

Top


Solstice documentation  | view source Contained in the Solstice distribution.