私は基本的に、暗号化アプリにhttp://www.avajava.com/tutorials/lessons/how-do-i-encrypt-and-decrypt-files-using-des.htmlのコードを使用しますが、できるようにしたいです動作モードを選択したので、これを追加しました:
private String key;
private static String algorithmMode;
public DESCrypt(String password, String algorithmMode) {
this.key = password;
this.algorithmMode = "DES/" + algorithmMode + "/PKCS5Padding";
}
メインは次のようになります。
public static void main(String[] args) {
try {
DESCrypt des = new DESCrypt("12345678", algorithmMode);
// FileInputStream fis1 = new FileInputStream("d:\\_test.txt");
// FileOutputStream fos1 = new FileOutputStream("d:\\_test.txt.des");
// des.encrypt(fis1, fos1);
FileInputStream fis = new FileInputStream("d:\\_test.txt.des");
FileOutputStream fos = new FileOutputStream("d:\\_test.txt");
des.decrypt(fis, fos);
} catch (Exception e) {
e.printStackTrace();
}
}
タイトルで言ったように、ECB では問題なく動作しますが、他のモードでは暗号化しかできません。