Java ,, 使用异或运算
实例 1 :
패키지 cn.std.util; import java.nio.charset.charset; public class deencode {private static final string key0 = "fecoi ()*& <mncxzpkl"; private static final charset = charset.forname ( "utf-8"); private static byte [] keybytes (charset); ENC) {byte [] b = enc.getBytes (charset); for (int i = 0, size = b.length; i <size; i ++) {for (byte keybytes0 : keybytes) {b [i] = (byte) (b [i]^keybytes0);}} return new String (b); public string decode (string) {dec) {rette {rette {rette (b)}} dec.getBytes (charset); byte [] dee = e; for (int i = 0, size = e.length; i <size; i ++) {for (byte keybytes0 : keybytes) {e [i] = (byte) (dee [i] keybytes0);}} public static void main (string) {args (argss)}. Right "; String Enc = Encode (s); String dec = decode (enc); System.out.println (Enc); System.out.println (dec);}}实例 2
public static string setencrypt (string str) {String sn = "ziyu"; // 密钥 int [] snnum = new int [str.length ()]; String result = ""; String temp = ""; for (int i = 0, j = 0; i <str.length (); i ++, j ++) {if (j == sn.length () j = 0; snnum [i] = str.charat (i)^sn.charat (j);} for (int k = 0; k <str.length (); k ++) {if (snnum [k] <10) {temp = "00"+snnum [k];} else {if (snnum [k] <100) {temp = "0"+snnum [k];}} result+= temp;} return result; i = 0, j = 0; i <str.length ()/3; i ++, j ++) {if (j == sn.length ()) j = 0; int n = integer.parseint (str.substring (i*3, i*3+3)); snnum [i] = (char) ((char) n^sn.charat (j)); k = 0; k <str.length ()/3; k ++) {result+= snnum [k];} return result;}}总结
以上就是本文关于 Java a a, 希望对大家有所帮助。感兴趣的朋友可以继续参阅本站其他相关专题, 如有不足之处, 欢迎留言指出。感谢朋友们对本站的支持! 欢迎留言指出。感谢朋友们对本站的支持!