这上面那个就是将byte[]加密的方法。
public static void main(String[] args) throws IOException {
File file = new File("C:\\Users\\libai\\Desktop\\s.pdf");
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
byte[] b = new byte[1000];
int n;
byte[] buffer;
while ((n = fis.read(b)) != -1) {
bos.write(b, 0, n);
}
fis.close();
bos.close();
buffer = bos.toByteArray();
File file1 = new File("C:\\Users\\libai\\Desktop\\x.pdf");
FileInputStream fis1 = new FileInputStream(file1);
ByteArrayOutputStream bos1 = new ByteArrayOutputStream(1000);
byte[] b1 = new byte[1000];
int n1;
byte[] buffer1;
while ((n1 = fis1.read(b1)) != -1) {
bos1.write(b1, 0, n1);
}
fis1.close();
bos1.close();
buffer1 = bos1.toByteArray();
String base64Encryption = Base64Encryption(buffer);
System.out.println("第一条"+base64Encryption);
String base64Encryption1 = Base64Encryption(buffer1);
System.out.println("第二条"+base64Encryption1);
}
不清楚是怎么回事?我是想加密多个文件,但是这样只是有最后一条的加密信息。求大神指点。