PHP kodu şu var:
$key="ed8677a0fc735e9bf1d7bca3310bb82854b5217589f2e00dd3bab399be9707a7";
$file="test";
$in = fopen($file, 'rb');
$out = fopen($file.'.encrypted', 'wb');
$file_size = filesize($file);
echo "[?] filesize: ".$file_size."\n";
echo "\n[?] KEY: $key \n";
$block_size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
// encrypt
echo date('Y-m-d H:i:s')."\n";
$time_s = time();
echo "[1] Encrypting.... \n";
$content='';
$encrypt=true;
$ip=0;
while (!feof($in)) {
$off_s = ftell($in);
$content = fread($in, 8192);
$off_e = ftell($in);
$size = $off_e-$off_s;
//if (($size!=8192)&&($size>0))
if ($size>0) {
if ($size!=8192)
$content = pkcs5_pad($content, $size, $block_size);
$encrypted = mcrypt_cbc(MCRYPT_RIJNDAEL_128, substr($key,0,32) ,$content, MCRYPT_ENCRYPT, substr($key,32,16));
fwrite($out, $encrypted);
}
}
fclose($in);
fclose($out);
Bunu nasıl Perl şifresini mi? Ben hiçbir başarı ile bu çalıştı:
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
use POSIX;
use File::Basename;
use Crypt::CBC;
use Digest::MD5 qw(md5 md5_hex);
# a) decrypt
my $key="ed8677a0fc735e9bf1d7bca3310bb82854b5217589f2e00dd3bab399be9707a7";
my $sourcefile="test.encrypted";
my $cipher = Crypt::CBC->new( {'key' => substr($key,0,32),
'cipher'=> 'Rijndael',
'blocksize' => 16,
'iv' => substr($key,32,16),
'regenerate_key' => 0,
'padding' => 'standard',
'prepend_iv' => 0,
'header' => 'none',
});
open (INF1, "< ".$sourcefile) || die;
open (OUTF1, "> ".$sourcefile.".decrypt") || die;
while (my $size = read(INF1,my $buf, 8192 ) ) {
$count += $size;
$buf2 = $cipher->decrypt($buf);
$buf2 .= $cipher->finish();
print OUTF1 $buf2;
#syswrite (OUTF1, $buf2, $size);
}
close(INF1);
close(OUTF1);
Ben dolgu ile bazı sorun olduğunu düşünüyorsanız - PHP ve Perl bunu yolu, ama uygun bir çözüm bulamıyor.