User Tools

Site Tools


guides:xor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
guides:xor [2017/09/19 13:24]
gorzilla [Intro]
guides:xor [2018/09/03 17:25] (current)
Line 36: Line 36:
  
 #​!/​usr/​bin/​env python ​ #​!/​usr/​bin/​env python ​
-import ​sys+import ​binascii
  
 def xor(s1,s2): def xor(s1,s2):
Line 48: Line 48:
 ciphertext=xor(plaintext,​repeat(key,​len(plaintext))) ciphertext=xor(plaintext,​repeat(key,​len(plaintext)))
  
-print(ciphertext.encode('​hex'​))+print(binascii.hexlify(str.encode(ciphertext)))
 </​code>​ </​code>​
 +
 +==== Further Reading ====
 +
 +[[https://​en.wikipedia.org/​wiki/​Exclusive_or|Wikipedia]]
 +
 +
 +[[https://​www.random.org/​bytes/​|RNG for one time pads]]
 +
 +[[https://​gchq.github.io/​CyberChef/​|CyberChef web app for XORing quickly]]
guides/xor.1505827485.txt.gz ยท Last modified: 2018/09/03 17:25 (external edit)