我正在尝试将整数转换为字符串,然后使用XOR加密对字符串进行加密.但是当我再次解密我的Strin时,我得到了一个不同的答案,即我在加密之前输入的字符串,我不知道我做错了什么?
public class Krypte {
public static void main (String [] args) {
int i = 12345;
String k = Integer.toString(i);
String G = secure(k.getBytes());
System.out.println("Encrypted: " + G);
String U = secure(G.getBytes());
System.out.println("Decrypted: " + U);
int X = Integer.parseInt(U);
System.out.println("As an int: " + X);
}
public static String secure(byte[] msg) {
// Variables
int outLength = msg.length;
byte secret = (byte) 0xAC; // same as 10101100b (Key)
// XOR kryptering
for (int i = 0; i < …Run Code Online (Sandbox Code Playgroud)