Re: Problems with RC5 (looks simple enough)

[email protected] (zentara) Fri, 12 Jul 2002 10:50:30 -0400
Newsgroups perl.crypto
Message-ID <[email protected]>
On Fri, 12 Jul 2002 18:21:25 +1000, [email protected] (Sisyphus)
wrote:

>
>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.


Yeah, I tried it on linux, and same problem. I don't think it handles
newlines right.  Crypt::Rijndael  and Crypt::RC4 work good.
#####################################################
#!/usr/bin/perl
use Crypt::RC5;

$key = 'e726';
$rc5 = new Crypt::RC5($key, '4' );

#this outputs correct
#$file = 'test test test test           test test test test';

#this outputs bad
$file = 'test test test test
         test test test test';

$cipher = $rc5->encrypt($file);

$rc5d = new Crypt::RC5($key, '4' );

$plain = $rc5d->decrypt($cipher);

print "$plain\n";
############################################################

Output:
test test test t              test test test