import java.util.Scanner;
public class Demo11 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("输入密码:");
String password = scanner.nextLine();
char[] p = password.toCharArray();
for(int i=0;i<p.length;i++)//与20000异或后进行加密
{
p[i]=(char)(p[i]^20000);
}
System.out.println("加密后的秘钥:");
System.out.println(new String(p));
for(int i=0; i<p.length; i++)//与20000再次异或后还原
{
p[i] = (char)(p[i]^20000);
}
System.out.println("原始密码为");
System.out.println(new String(p));
}
}
Demo015_异或进行加密
最新推荐文章于 2019-09-10 19:58:19 发布