Aut::Crypt - Symmetric encryption for Aut


Aut documentation Contained in the Aut distribution.

Index


Code Index:

NAME

Top

Aut::Crypt - Symmetric encryption for Aut

ABSTRACT

Top

This module provides an easy interface to Crypt::CBC to use with the Aut framework. It uses blowfish to encrypt/decrypt stuff.

DESCRIPTION

Top

new(seed) --> Aut::Crypt

Instantiates a new Aut::Crypt object with given seed value as encryption key.

encrypt(plaintext) --> ciphertext

Encrypts the given plaintext using Crypt::CBC's encrypt function with key 'seed' and cipher 'Blowfish'. Returns the encrypted ciphertext as is.

decrypt(ciphertext) --> plaintext

Decrypts the given ciphertext using Crypt::CBC's decrypt function with key 'seed' and cipher 'Blowfish'. Returns the plaintext as is. There's no check weather the decryption resulted in anything valid. This has to be checked by the caller.

A simple practice is to prepend a plaintext with some other known plaintext and use the other plaintext to check if the decryption resulted in anything really plain.


Aut documentation Contained in the Aut distribution.

package Aut::Crypt;

# $Id: Crypt.pm,v 1.2 2004/04/08 16:55:13 cvs Exp $ 

use Crypt::CBC;
use strict;

sub new {
  my $class=shift;
  my $key=shift;
  my $self;

  $self->{"key"}=$key;

  bless $self,$class;
return $self;
}

sub encrypt {
  my $self=shift;
  my $text=shift;
  my $cbc=new Crypt::CBC( { 'key' => $self->{"key"}, 'cipher' => 'Blowfish' } );
return $cbc->encrypt($text);
}

sub decrypt {
  my $self=shift;
  my $text=shift;
  my $cbc=new Crypt::CBC( { 'key' => $self->{"key"}, 'cipher' => 'Blowfish' } );
return $cbc->decrypt($text);
}

1;
__END__