Thread Crypt::Rijndael und die blocksize (4 answers)
Opened by styx-cc at 2007-11-25 04:11

styx-cc
 2007-11-25 04:11
#102969 #102969
User since
2006-05-20
533 Artikel
BenutzerIn

user image
Hallo, ich habmir zum spielen was gebastelt, allerdings bin ich auf ein Prolem gestossen, und zwar verschluesselt mir das Script die Strings nur wenn deren Groesse durch die blocksize (Standartmaessig 16 byte) teilbar ist anderfalls gibts ne Fehlermeldung "encrypt: datasize not multiple of blocksize (16 bytes) at aes.txt line 15.":

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl

use strict;

use warnings;

use Crypt::Rijndael;
use Digest::MD5 qw/md5_hex/;


my $password = $ARGV[0] || 1;
my $cipher = Crypt::Rijndael->new(md5_hex($password), Crypt::Rijndael::MODE_CBC() );


print decrypt( encrypt('testtesttesttest') );

sub encrypt {
my $plain = shift;
#$plain must be a multiple of 16 (in bytes)
my $crypted = $cipher->encrypt($plain);
return $crypted;
}

sub decrypt {
my $crypted = shift;
my $plain = $cipher->decrypt($crypted);

return $plain;
}


Wie bekomme ich nun variierende Strings dazu immer durch 16bytes teilbar zu sein, ohne sie zu veraendern?

MfG
Pörl.

View full thread Crypt::Rijndael und die blocksize