📄 jiami.java
字号:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.*;
import javax.swing.JOptionPane;
public class Jiami {
//@SuppressWarnings("empty-statement")
public static void main(String[] args) throws IOException{
//加密
String message=JOptionPane.showInputDialog(null,"请输入您要加密的语句:");
String secre1=JOptionPane.showInputDialog(null,"请输入你的密码(最好是数字):");
char[] c = (secre1+"*************************************************" +
"*****************************************************************" +
"*****************************************************************" +
"********************************************************").toCharArray();//构建密码
char[] a = (message+"&").toCharArray();//讲加密语句转化到数组中以便进行异或加密操作
byte[] d = new byte[300];//该数组用来保存密文
for (int i = 0; i < a.length; i++) {
a[i] = (char) (a[i] ^ c[i]);//将原文或密钥进行异或操作
d[i] = (byte) (a[i]);//保存密文
}
FileOutputStream output=new FileOutputStream("加密后的文件.txt");
output.write(d);//将加密后的密文保存到问件
JOptionPane.showMessageDialog(null, "文件加密成功,已经保存在程序当前目录下的《加密后的文件.txt》中","密文",JOptionPane.QUESTION_MESSAGE);
}//输出加密成功信息给客户
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -