Reversible crypto system using XOR logical gate
How to create a reversible crypto system using XOR logical gate ?
We have various logical operators like OR, AND etc. Among them XOR can be implemented easily and can be understood.
XOR hasthe following advantages when used for cryptography:
We have various logical operators like OR, AND etc. Among them XOR can be implemented easily and can be understood.
XOR hasthe following advantages when used for cryptography:
- Very fast computable, especially in hardware.
- Not making a difference between the right and left site. (Being commutative.)
- It doesn't matter how many and in which order you XOR values. (Being associative.)
- Easy to understand and analyse.
When we are implementing Xor, the secret key should be having the length equal to the plain text.
------------------------------------------------------------------------------------------------------------------------
XOR Encryption Decryption :
def EncryptionDecryption(input,key):
output = []
for i in range(len(input)):
xor_num = ord(input[i]) ^ ord(key[i])
output.append(chr(xor_num))
return ''.join(output)
def main():
plainText = input ("Enter Plain Text :")
SecretKey = input ("Enter Secret Key :")
encrypted = encryptDecrypt(plainText,SecretKey);
print("Encrypted:"+encrypted);
decrypted = encryptDecrypt(encrypted,SecretKey);
print("Decrypted:"+decrypted);
if __name__ == '__main__':
main()
--------------------------------------------------------------------------------------------------------------------------
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment