?? aesdecryption.java
字號:
package src;
import java.io.*;
import javax.crypto.spec.*;
import javax.crypto.*;
public class AESDecryption {
public static void main(String[] args) {
try {
String afterEncrypt = "cipher.txt";
String afterDecrypt = "final.txt";
byte[] cipherkey = KeyCipher.loadKey(afterEncrypt);
byte[] b = new byte[64];
System.arraycopy(cipherkey, 0, b, 0, 64);
byte[] aesKey = RSADecryption.decrypt(GetRSAKey.GetPrivateKey(), b);
SecretKey aks = new SecretKeySpec(aesKey, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, aks);
BufferedOutputStream out = new BufferedOutputStream(
new FileOutputStream(afterDecrypt));
CipherInputStream in = new CipherInputStream(
new BufferedInputStream(new FileInputStream(afterEncrypt)),
cipher);
int i;
do {
i = in.read();
if (i != -1)
out.write(i);
} while (i != -1);
in.close();
out.close();
byte[] fss = KeyCipher.readFile(afterDecrypt);
int length = fss.length;
byte[] cut = new byte[length-64];
System.arraycopy(fss, 64, cut, 0, length-64);
String s = new String(cut);
FileWriter fw = null;
fw = new FileWriter(afterDecrypt);
fw.write(s);
fw.close();
System.out.println("Decryption is successful!");
} catch (Exception e) {
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -