Re: Problems with RC5 (looks simple enough)

[email protected] ("Sisyphus") Fri, 12 Jul 2002 18:21:25 +1000
Newsgroups perl.crypto
Message-ID <002801c2297d$200bf2e0$aa928bca@sisyphusii330h>
----- Original Message -----
From: "John Francis" <[email protected]>
>
> #!/usr/bin/perl
>
>         use IO::Socket;
>         use Crypt::RC5;
> #http://search.cpan.org/doc/SIFUKURT/Crypt-RC5-1.01/RC5.pm
>
>         $key = 'e726c4973ddd9c671cc07f8eef0f08b2';
>         $rc5 = new Crypt::RC5($key, '12' );
>
>         open(FILE,"/etc/passwd");
>         while(<FILE>){
>                 $file .= $_;
>         }
>         close(FILE);
>
>   $stuffing = length($file)%8;
>
>         for($i = 0;$i<$stuffing;$i++){
>                 $file .='#';
>         }
> # Since RC5 takes word input of size 8, i stuff the data with
>         # pound signs to make sure it is properly sized
>
>         $cipher = $rc5->encrypt($file);
>
>         $plain = $rc5->decrypt($cipher);
>
>         $plain =~ s/\#+$//;
>
>         print $plain;
>

Doesn't work for me either on Win2k, though afaik your code is ok. (Someone
might confirm that it even works on nix ??)

If you 'chomp' off the newlines as you read, then you get less garbage - but
it's still not right.

Maybe Crypt::CBC would do ?

Cheers,
Rob