📄 aes1.java
字号:
package com.ss;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.SecureRandom;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
public class AES1 {
public static void main(String[] args) throws Exception {
String pwd ="abcdefghabcdefgh";
File file = new File("H:/PunishListEn20070918154714-20872.xml");
//System.out.println(file.length());
//encryptfile (pwd, file);
}
public String encryptfile(String pwd, File file) throws Exception
{
int i = 0;
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
byte[] bytIn = new byte[(int)file.length()];
bis.read(bytIn);
bis.close();
byte[] raw = pwd.getBytes("ASCII");
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
String doc = "";
try{
byte[] bytOut = cipher.update(bytIn);
doc = new String (bytOut);
}catch(Exception e){
e.printStackTrace();
}
return doc;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -