0

ファイルを perl で暗号化しており、Java で復号化したいと考えています。ここに私の暗号化コードがあります:

== Perl での暗号化 ==

$key = "1234567890123456";
$plain_text = "this is foo";
open ($fh, ">" . $output_file_path) || die ("open ($output_file_path):$!");
my $cipher = Crypt::CBC->new( -key => $key, -cipher => "Crypt::OpenSSL::AES");
$cipher->start("");
print $fh $cipher->crypt($plain_text);

これは私が使用している復号化コードですが、機能していません。

== Java での復号化 ==

String key = "1234567890123456";
byte[] encrypted_bytes = READ_DATA_FROM_FILE
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(), "AES");
IvParameterSpec ivSpec = new IvParameterSpec(key.getBytes());
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivSpec);
String plain_text = new String(cipher.doFinal(encrypted_bytes));

誰かがこれで私を助けることができますか?

4

1 に答える 1