您的位置:首页 > 其它

IO-加密工具

2020-08-16 15:53 330 查看
public static void main(String[] args) throws IOException {
System.out.println("请输入文件的全路径");
Scanner scanner = new Scanner(System.in);
String filename = scanner.nextLine();
//原文件
File oldFile = new File(filename);
//加密文件    加前缀mi-
File newFile = new File(oldFile.getParent(),"mi-"+oldFile.getName());
FileInputStream fis = new FileInputStream(oldFile);
FileOutputStream fos = new FileOutputStream(newFile);
while (true){
int b = fis.read();
if(b==-1){
break;
}
//任何数据^10两次  结果还是其本身   加密解密过程
fos.write(b^10);

}
System.out.println("加密或解密完成");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: