暗号化
Crypt::CBCなどのモードとCrypt::Twofishなどのブロック暗号モジュールを利用します。
use strict;
use Crypt::CBC;
my $cipher = Crypt::CBC->new({
'key' => 'Secret', # 暗号化キー
'cipher' => 'Twofish_PP', # 暗号化方式(今回はCrypt::Twofish_PP)
'iv' => '1k9zLLLL', # 初期化ベクトル(IV)
'regenerate_key' => 1, # 暗号化キーのハッシュ化フラグ
'padding' => 'standard', # パディング方式
'prepend_iv' => 0, # IVを先頭に付加フラグ
});
# 平文
my $plaintext = "元の文字列";
# 暗号化
my $ciphertext = $cipher->encrypt($plaintext);
# 復号
my $decrypttext = $cipher->decrypt($ciphertext);
print "Plain text : ", $plaintext, "\n";
#print "Cipher text : ", $ciphertext, "\n";
print "Decrypt text: ", $decrypttext, "\n";
