Java 简单的加密解密算法 , 使用异或运算
实例 1:
Paket cn.std.util; import Java.nio.charset.CharSet; öffentliche Klasse Decod {private static Final String key0 = "fecoi ()*& <mncxzpkl"; private statische endgültige charset = charset.forname ("utf-8"); private static byte [] keyByTes = key0.getB ("; Enc) {byte [] b = Enc.getBytes (charSet); für (int i = 0, size = b.Length; i <size; i ++) {für (byte keyBytes0: keyBytes) {b [i] = (byte) (b [i]^keyBytes0); 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);}}return new String(e);}public static void main(String[] args) {String s="you are rechts "; String Enc = Encodes (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 = ""; für (int i = 0, j = 0; i <str.Length (); i ++, j ++) {if (j == Sn.Length ())) {if (j == Sn.Length ()))). J = 0; sonst {if (snnum [k] <100) {temp = "0"++snnum [k];}} result+= temp;} return result;} public static String getencrypt (String str) {String sn = "ziyu"; // 密钥 char [] snnum = new char [str.length ()/3]; i = 0, j = 0; i <str.length ()/3; i ++, j ++) {if (j == Sn.Length ()) J = 0; int n = Integer. k = 0; k <str.length ()/3; k ++) {result+= snnum [k];} Rückgabeergebnis;}}总结
以上就是本文关于 Java 使用异或运算实现简单的加密解密算法实例代码的全部内容 , 希望对大家有所帮助。感兴趣的朋友可以继续参阅本站其他相关专题 , 如有不足之处 , 欢迎留言指出。感谢朋友们对本站的支持! 欢迎留言指出。感谢朋友们对本站的支持! 欢迎留言指出。感谢朋友们对本站的支持!