如何在Perl中處理Crypt :: Blowfish的非ANSI字符?如何在Perl中處理Crypt :: Blowfish的非ANSI字符?
以下腳本是以字符集UTF-8編寫的,僅在§
或ö
上失敗。
#!/usr/bin/env perl
use strict;
use warnings FATAL => 'all';
use utf8;
use Crypt::Blowfish;
my $cipher = Crypt::Blowfish->new(pack 'H16', '12345678');
my @chars = ('a', '§', 'ö', '9');
printf("%s: %s",
$_, (eval { $cipher->encrypt($_ x 8) }) ? "ok\n" : "fail: [email protected]")
for (@chars);