DES-CBCを実装しています。私は何をしているのか混乱してcipher.init
いcipher.update
ますcipher.dofinal
。init を使用してキーを設定しdofinal
、結果を取得するだけです。アップデートは使いません。あれは正しいですか?
また、 UTF-8とASCIIエンコーディングを使用した場合の結果の違いは何ですか?
これが私のコードです:
byte[] ciphertext;
Cipher enc = Cipher.getInstance("DES/CBC/PKCS5Padding");
enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "DES"), new IvParameterSpec(vector));
// Is this the complete ciphertext?
ciphertext = encrypt.doFinal(data.getbytes("UTF-8"));