使用XOR门编码解码 [英] Encoding decoding using XOR gate
问题描述
hi
i需要为此创建个人编码方法
例如我有字符串参数A =P @ ssw0rd和B = 0xffa1
C = A XOR B
C是我的结果
很清楚
但在解码时
我必须用什么算子从C和B得到A ????
A = C(什么算子)B ??????
我的尝试:
字符串A =P @ ssw0rd;
string B = 0xffa1;
C = A XOR B
同一个!
XOR B == C
C XOR B == A
但是TBH XOR不是一个很好的加密算法,它太容易了打破 - 你不应该加密密码!您应该隐藏密码,而不是加密密码:密码存储:如何操作它。 [ ^ ]
按位XOR
操作是可逆的:
(a xor b)xor b = a
因此,如果可能已经完成,你可以撤销XOR
'ecryption'只需XOR
再次使用相同的密钥。
< blockquote class =quote>引用:但在解码时
我必须使用哪个运算符从C和B中获取A ???? / blockquote>
相同
第二个xor取消第一个。
所以当你有C = A xor B
,您还将A = C xor B
和B = A xor C
具有相同的A,B,C值。
hi
i need to create method for personal encoding like this
for example i have string parameter A = "P@ssw0rd" and B = 0xffa1
C = A XOR B
C is my result
it's clear
but in decoding
what operator i have to use to get A from C and B????
A = C (what operator) B ??????
What I have tried:
string A = "P@ssw0rd"; string B = 0xffa1; C = A XOR B
The same one!
A XOR B == C C XOR B == A
But TBH XOR is not an good encryption algorithm, it's far, far too easy to break - and you shouldn't be encrypting passwords anyway! You should Hash your passwords, not encrypt them: Password Storage: How to do it.[^]
Bitwise theXOR
operation is reversible:
(a xor b) xor b = a
hence, if probably done, you can reverse theXOR
'ecryption' simplyXOR
ing again with the same key.
Quote:but in decoding
what operator i have to use to get A from C and B????
Same
A second xor cancel the first one.
So when you haveC=A xor B
, you will also haveA=C xor B
andB=A xor C
with same values for A,B,C.
这篇关于使用XOR门编码解码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!