Java簡單的加密解密算法,使用異或運算
實例1:
軟件包CN.STD.UTIL;導入Java.nio.Charset.Charset; public Class class deencode {私有靜態最終字符串key0 =“ fecoi()*&<mncxzpkl”; private static charset charset = charset = charset = charset = charset.forname = charset.forname(“ enc){byte [] b = enc.getBytes(charset); for(int i = 0,size = b.length; i <size; i ++; i ++){for(byte keybytes0:keybytes){b [i] =(byte)=(byte)(byte)(b [b [i]^keybyTes0); execyBeytes0);}} by new string(b); dec.getBytes(charset); byte [] dee = e; for(int i = 0,size = e.length; i <size; i ++; i ++){for(byte keybytes0:keyBytes){e [e [i] =(byte)=(byte)(dee [e [i]^keybytes0);右”; string enc = encode(s);字符串dec = decode(enc); system.out.println(enc); system.out.println(dec);}}}實例2
公共靜態字符串SetEnCrypt(string str){字符串sn =“ ziyu”; //密鑰int [] snnum = new int [str.length(); string result =“”; string temp =“”; for(int i = 0,j = 0,j = 0; i <str.length(i <str.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” 00“ 00”+snnum [k];};};};} else {if(snnum [k] <100){temp =“ 0”+snnum [k];}}結果+= temp;}返回結果;} public static String string getEncrypt(string str){字符串sn =“ ziyu”; ////////////// 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+3); k = 0; k <str.length()/3; k ++){結果+= snnum [k];}返回結果;}}}總結
以上就是本文關於java使用異或運算實現簡單的加密解密算法實例代碼的全部內容,希望對大家有所幫助。感興趣的朋友可以繼續參閱本站其他相關專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持! ,歡迎留言指出。感謝朋友們對本站的支持!