当前我正在使用异或加密编程聊天。但今天我遇到了一个问题。 Windows中的加密与Linux中的不同。在Linux下,聊天正常运行,但在Windows下不行。异或用Linux和Windows加密不同
这里的类:
class XOR_c {
private boolean active = true;
private int key;
// Constructor
public XOR_c(int k){
if (System.getProperty("os.name").contains("Windows")) {
JOptionPane.showMessageDialog(null,"No encryption!","Client", JOptionPane.CANCEL_OPTION);
this.active = false;
}
key = k;
}
public String encode(String s) {
if (active == false) return s;
char[] c = s.toCharArray();
for (int i=0; i
c[i] = (char)(c[i]^key);
return new String(c);
}
public String decode(String s){
return encode(s);
}
}
这与openSUSE的,Debian和Windows 7的
现在如何解决它的测试(在这一刻我为加密旁路但这不是我的目标,我想要两个系统加密)?我的源错了吗?
2013-06-11
Zaziki
+1
System.getProperty(“os.name”)。contains(“Windows”)在Windows机器上是成立的,所以它明确地禁用了你的加密。你有一些其他代码可以删除这段代码或者使用其他方法吗? –
+2
拥有xor加密就像没有加密。你知道吗? –
+1
你能举一个例子,说明Windows上出了什么问题吗?即当你用新的XOR_c(42)编码“abc”,然后用相同的XOR_c解码它时,它是否不返回“abc”? –