| Solstice documentation | view source | Contained in the Solstice distribution. |
Solstice::Encryption - Solstice's standard two-way encryption library.
use Solstice::Encryption; my $encrypter = Solstice::Encryption->new; my $ciphertext = $encrypter->encrypt($string); my $string = $encrypter->decrypt($ciphertext);
Will encrypt/decrypt a string using the Rijndael algorithm (aes).
No symbols exported.
Constructor. Returns an encrypter object.
Returns the encrypted version of the plain_text_string in URL safe text.
sub encryptHex { my $self = shift; my $pt = shift; return unpack "H*", $self->_encrypt($pt); }
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);
}
Returns the decrypted version of the encrypted_string
sub decryptHex { my $self = shift; my $cipher = shift; return undef unless (defined $cipher && $cipher); return $self->_decrypt(pack "H*", $cipher); }
sub _decrypt { my $self = shift; my $et = shift; my $padded; eval{ $padded = $self->_getCipher()->decrypt($et); };
$padded =~ s/^[ ]*//;
return $padded;
}
Catalyst Group, <catalyst@u.washington.edu>
$Revision: 3364 $
Copyright 1998-2007 Office of Learning Technologies, University of Washington
Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.opensource.org/licenses/ecl1.php
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
| Solstice documentation | view source | Contained in the Solstice distribution. |