public class MyString
{
public static void main(String[] args)
{
String key = "$%&^&%$*$%%^&%&$&&%";
String s = "abcd中国";
char[] c1 = key.toCharArray();
char[] c2 = s.toCharArray();
for(int i=0; i<c2.length; i++){
c2[i] ^= c1[i]; // 在原基础上“异或”
}
String s2 = new String(c2);
System.out.println(s2);
/*
String s = "abcd中国";
char[] cc = s.toCharArray();
for(int i=0; i<cc.length; i++){
cc[i]++;
}
String s2 = new String(cc);
System.out.println(s2);
*/
}
} |