Crypt::CBC
2013年2月22日 Perl コメント (2)Crypt::CBC のメモ
Crypt::Blowfish と Crypt::CBC を使用。使う際は事前に用意しておく必要アリ。
ppm install --force Crypt::Blowfish
ppm install --force Crypt::CBC
$cipher->start(’encrypting’);
$content = $cipher->crypt($content);
$cipher->finish();
この箇所は
$cipher->encrypt("$content");
の方が分かり易いか。
複合化する場合は
または
とする。
Crypt::Blowfish と Crypt::CBC を使用。使う際は事前に用意しておく必要アリ。
ppm install --force Crypt::Blowfish
ppm install --force Crypt::CBC
#!/usr/bin/perl
use strict;
use warnings;
use Crypt::CBC;
my $content = qq||;
open(FH,"[plane_file]");
while(){ $content .= $_; }
close(FH);
my $key = ’crypt key’;# key
my $cipher = new Crypt::CBC($key,’Blowfish’);
$cipher->start(’encrypting’);
$content = $cipher->crypt($content);
$cipher->finish();
open(FH,"> [crypt_file]");
print FH $content;
close(FH);
exit;
$cipher->start(’encrypting’);
$content = $cipher->crypt($content);
$cipher->finish();
この箇所は
$cipher->encrypt("$content");
の方が分かり易いか。
複合化する場合は
$cipher->start(’decrypting’);
$content = $cipher->crypt($content);
$cipher->finish();
または
$cipher->decrypt("$content");
とする。
コメント