异或方法 : 可逆,不安全(不常用)
public class test {
public static String xor(String str){
char[] cha = str.toCharArray();
for (int i = 0; i < cha.length; i++) {
//cha[i]=(char)(cha[i]^3000);
cha[i]^=3000;
}
return new String(cha);
}
public static void main(String[] args) {
String s="hello";
//第一次异或(加密)
s = xor(s);
System.out.println(s);
//第二次异或(解密)
s = xor(s);
System.out.println(s);
}
}