私はchilkat
機能を使用してファイルの暗号化をテストしようとしていました。 this例のページで見つけたコードに基づいて、私はこれで最後の部分を置き換え:Chilkatの暗号化が期待通りに機能しない
# Encrypt a string...
# The input string is 44 ANSI characters (i.e. 44 bytes), so
# the output should be 48 bytes (a multiple of 16).
# Because the output is a hex string, it should
# be 96 characters long (2 chars per byte).
my $input = "sample.pdf";
# create file handle for the pdf file
open my $fh, '<', $input or die $!;
binmode ($fh);
# the output should be sample.pdf.enc.dec
open my $ffh, '>', "$input.enc.dec" or die $!;
binmode $ffh;
my $encStr;
# read 16 bytes at a time
while (read($fh,my $block,16)) {
# encrypt the 16 bytes block using encryptStringEnc sub provided by chilkat
$encStr = $crypt->encryptStringENC($block);
# Now decrypt:
# decrypt the encrypted block
my $decStr = $crypt->decryptStringENC($encStr);
# print it in the sample.pdf.enc.dec file
print $ffh $decStr;
}
close $fh;
close $ffh;
免責事項: 私は1つのブロックが失われた場合、他のブロックが失われているためCBCモードは、ファイルの暗号化のために推奨されません知っていますあまりにも。 出力ファイルが壊れていて、2つのファイルを比較して比較すると、一致するファイルのチャンクがあり、一致しないファイルのチャンクがあります。私は間違って何をしていますか?
'$ crypt'オブジェクトの種類がわからないと助けができません。どのように作成されますか? –
@DaveCrossクイック検索では、これが* * fckであることがわかります。これをすべて1クラス* - [CkCrypt2](https://www.chilkatsoft.com/refdoc/vcCkCrypt2Doc.html)コンポーネントで行いましょう。 –
@MaartenBodewes:C++ではなく、[Perlモジュール](https://www.chilkatsoft.com/refdoc/perlCkCrypt2Ref.html)にリンクすることを意味します。しかし、私の主張は、私たちがその検索をする必要はないはずだったということでした。 –