package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Base64;
public class Test {
//测试output
@org.junit.Test
public void testImg() throws IOException{
File file = new File("E:/test/6.jpg");
FileInputStream inputFile = new FileInputStream(file);
byte[] buffer = new byte[(int)file.length()];
System.out.println("文件大小:"+file.length());
inputFile.read(buffer);
inputFile.close();
System.out.println(buffer);
byte[] aa = Base64.getEncoder().encode(buffer);
System.out.println(aa);
System.out.println("加密后大小:"+aa.length);
//System.out.println(dd);
byte[] bb = Base64.getDecoder().decode(aa);
System.out.println("解密后大小:"+bb.length);
System.out.println(bb);
File
图片base64加密,解密测试
最新推荐文章于 2024-05-13 15:24:32 发布
这篇博客探讨了如何使用Base64进行图片的加密和解密操作,通过代码示例展示了具体实现过程。
摘要由CSDN通过智能技术生成