?? unencrypt.java
字號:
package encryptandunencrypt;
import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
public class UnEncrypt {
private String fenge = java.io.File.separator;
public void UnEncrypt() throws Exception {
//僼傽僀儖傪僥僗僩偟偰懚嵼偡傞偐偳偆偐丅
String encryptedFileExist = "bo" + fenge + "encrypt" + fenge +
"bnavie_exp_enc.xml";
File fileName = new File(encryptedFileExist);
boolean result = fileName.exists();
if (!result) {
return;
} else {
//岞奐尞傪宍惉偡傞
byte[] keykb = {
28, -1, 64, 64, 71, 106, 1, 72, -31, 47, -108, -75,
-110,
78, 33, 105};
SecretKeySpec secretKeySpec = new SecretKeySpec(keykb, "BlowFish");
//the file name of unencrypt丅
String encrypt = "bo" + fenge + "unencrypt" + fenge +
"bnavie_exp.xml";
try {
//埫崋壔偺曽幃傪憂寶偟偰弶婜壔偡傞丅
Cipher cipher = null;
cipher = Cipher.getInstance("BlowFish");
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
//憂寶偺埫崋壔偡傞偺偼晧偗偰帪悽偵崌偆丅
FileInputStream fileInputStream = null;
fileInputStream = new FileInputStream(encryptedFileExist);
//CipherInputStream懳徾傪憂寶偡傞丅
CipherInputStream cipherInputStream = new CipherInputStream(
fileInputStream, cipher);
//強偼枾側(cè)寢壥傪棟夝偡傞丅
FileOutputStream fileOutputStream = null;
fileOutputStream = new FileOutputStream(encrypt);
//晧偗傞偙偲傪摼偰帪悽偵崌偆丅
int b = 0;
while ((b = cipherInputStream.read()) != -1) {
fileOutputStream.write(b);
}
//偡傋偰偺桝弌擖傪暵嵔偟偰棳傟傞丅
fileInputStream.close();
cipherInputStream.close();
fileOutputStream.close();
//嶍彍偟偰埫崋壔偟偨屻偺僥儞億儔儕僼傽僀儖丅
String xmlField = "bo" + fenge + "unencrypt" + fenge +
"bnavie_exp_enc.xml";
File xmlFile = new File(xmlField);
xmlFile.delete();
} catch (Exception ex) {
ex.printStackTrace();
throw ex;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -