home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / IDEA.pm < prev    next >
Encoding:
Perl POD Document  |  2001-05-02  |  1.3 KB  |  65 lines

  1. # $Id: IDEA.pm,v 1.7 2001/05/02 21:59:33 btrott Exp $
  2.  
  3. package Net::SSH::Perl::Cipher::IDEA;
  4.  
  5. use strict;
  6.  
  7. use Net::SSH::Perl::Cipher;
  8. use base qw( Net::SSH::Perl::Cipher );
  9.  
  10. use Net::SSH::Perl::Cipher::CFB;
  11. use Crypt::IDEA;
  12.  
  13. sub new {
  14.     my $class = shift;
  15.     my $ciph = bless { }, $class;
  16.     $ciph->init(@_) if @_;
  17.     $ciph;
  18. }
  19.  
  20. sub init {
  21.     my $ciph = shift;
  22.     my($key, $iv) = @_;
  23.     my $idea = IDEA->new(substr $key, 0, 16);
  24.     $ciph->{cfb} = Net::SSH::Perl::Cipher::CFB->new($idea, $iv);
  25. }
  26.  
  27. sub encrypt {
  28.     my($ciph, $text) = @_;
  29.     $ciph->{cfb}->encrypt($text);
  30. }
  31.  
  32. sub decrypt {
  33.     my($ciph, $text) = @_;
  34.     $ciph->{cfb}->decrypt($text);
  35. }
  36.  
  37. 1;
  38. __END__
  39.  
  40. =head1 NAME
  41.  
  42. Net::SSH::Perl::Cipher::IDEA - Wrapper for SSH IDEA support
  43.  
  44. =head1 SYNOPSIS
  45.  
  46.     use Net::SSH::Perl::Cipher;
  47.     my $cipher = Net::SSH::Perl::Cipher->new('IDEA', $key);
  48.     print $cipher->encrypt($plaintext);
  49.  
  50. =head1 DESCRIPTION
  51.  
  52. I<Net::SSH::Perl::Cipher::IDEA> provides IDEA encryption
  53. support for I<Net::SSH::Perl>. To do so it wraps around
  54. I<Crypt::IDEA>, a C/XS implementation of the IDEA algorithm.
  55.  
  56. The IDEA algorithm used here is in CFB filter mode with a
  57. key length of 16 bytes.
  58.  
  59. =head1 AUTHOR & COPYRIGHTS
  60.  
  61. Please see the Net::SSH::Perl manpage for author, copyright,
  62. and license information.
  63.  
  64. =cut
  65.