mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
Added python implementation
This commit is contained in:
parent
aa702ca4c7
commit
8e32db167b
31
Python/XOREncryption.py
Normal file
31
Python/XOREncryption.py
Normal file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
"""
|
||||
XOREncryption.py
|
||||
|
||||
Created by Kyle Banks on 2013-10-06.
|
||||
"""
|
||||
|
||||
def encryptDecrypt(input):
|
||||
key = ['K', 'C', 'Q'] #Can be any chars, and any size array
|
||||
output = []
|
||||
|
||||
for i in range(len(input)):
|
||||
xor_num = ord(input[i]) ^ ord('K')
|
||||
output.append(chr(xor_num))
|
||||
|
||||
return ''.join(output)
|
||||
|
||||
|
||||
def main():
|
||||
encrypted = encryptDecrypt("kylewbanks.com");
|
||||
print("Encrypted:"+encrypted);
|
||||
|
||||
decrypted = encryptDecrypt(encrypted);
|
||||
print("Decrypted:"+decrypted);
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user