Crypt::CBC

2013年2月22日 Perl コメント (2)
Crypt::CBC のメモ
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");

とする。

コメント

Lag
Lag
2013年2月22日21:00

Cryptを見てマナクリプトだと思ったのは僕だけじゃないと信じたい

shima
2013年2月22日21:07

[cipher]の箇所がキーワード能力の[暗号]にも当てはまりますね > Lagさん

最新の日記 一覧

<<  2025年6月  >>
1234567
891011121314
15161718192021
22232425262728
293012345

お気に入り日記の更新

この日記について

日記内を検索