文本文件的加密,解密(其它类似)
来源:互联网 发布:xp网络共享文件夹 编辑:程序博客网 时间:2024/05/09 17:54
import java.io.FileInputStream;
import java.io.FileOutputStream;
/**
* 文本文件的加密,解密
*
* @author user
*
*/
public class TextFileTest {
public static void main(String[] args) throws Exception {
TextFileTest f = new TextFileTest();
f.encryption("C:/Documents and Settings/user/桌面/a.txt",
"D:/yinyaogen/homework/MyJavaSample/src/day10/Day10.txt");
f.decryption("C:/Documents and Settings/user/桌面/b.txt",
"C:/Documents and Settings/user/桌面/a.txt");
}
/**
* 加密
*/
public void encryption(String url1, String url2) throws Exception {
FileOutputStream fileOutputStream = new FileOutputStream(url1);
FileInputStream fileInputStream = new FileInputStream(url2);
// byte[] arr = new byte[1024];
// int i = fileInputStream.read(arr);
int i = ~fileInputStream.read();
byte[] arrByte = new byte[1024];
int index = 0;
while (i != -1) {
char c = (char) i;
if (c < 256) {
c += 30;
i = c+30;
}
arrByte[index++] = (byte) i;
while (index == 1024) {
fileOutputStream.write(arrByte, 0, arrByte.length);
index = 0;
}
i = fileInputStream.read();
if(i == -1)
fileOutputStream.write(arrByte, 0, index-1);
}
System.out.println(2*2*2*2*2*2*2*2);
fileInputStream.close();
fileOutputStream.close();
}
/**
* 解密
*/
public void decryption(String url1, String url2) throws Exception {
FileOutputStream fileOutputStream = new FileOutputStream(url1);
FileInputStream fileInputStream = new FileInputStream(url2);
// byte[] arr = new byte[1024];
int i = ~fileInputStream.read();
byte[] arrByte = new byte[1024];
int index = 0;
while (i != -1) {
char c = (char) i;
if (c < 286) {
c -= 30;
i = c-30;
}
arrByte[index++] = (byte) i;
while (index == 1024) {
fileOutputStream.write(arrByte, 0, arrByte.length);
index = 0;
}
i = fileInputStream.read();
if(i == -1)
fileOutputStream.write(arrByte, 0, index-1);
}
fileInputStream.close();
fileOutputStream.close();
}
}
- 文本文件的加密,解密(其它类似)
- 对文本文件的加密解密
- Qt 文本文件的简单加密解密
- C++ <文本文件的加密与解密>
- java 文本文件加密 文本文件解密
- 文本文件加密解密(一)
- 给文本文件加密解密
- ionCube 一款类似zend的PHP加密/解密工具
- [Java学习] java文本文件加密解密类
- 深入理解C实现文本文件的加密解密,读取长度操作
- 读取被其它进程占用的文本文件
- 【加密解密】对字符串的加密解密
- C++异或加密\解密文本文件(编译+链接+批处理)
- Java IO4 实现凯撒密码加密解密文本文件
- 简单的加密解密
- DataSet的加密解密
- . net的加密解密
- 简单的加密解密
- 全面了解几种Red Hat的版本
- java 计算时间差
- 怎么学好C#
- day11 线程同步 使用 File 创建目录和文件 常用的 IO 流
- 一个文件中保存一首唐诗,用字符流流进行复制,复制到新文件中的诗,所有的内容倒序输出。
- 文本文件的加密,解密(其它类似)
- URL
- Oracle常见实用的函数总结(更新...)
- 见与不见
- 1的数目
- VB 6.0 控件不能拖动
- 脚本语言
- 比较规整通用的二分查找
- 如何使用ERwin进行基于Mysql的数据库设计