Skip to content

Instantly share code, notes, and snippets.

@strboul
Created September 24, 2022 13:08
Show Gist options
  • Save strboul/685d484e310d0723757f05327246ff70 to your computer and use it in GitHub Desktop.
Save strboul/685d484e310d0723757f05327246ff70 to your computer and use it in GitHub Desktop.
import string
import random
message = "hello world from python"
# secret = ''.join(random.choices(string.ascii_uppercase + string.digits, k=100))
secret = 'bob'
encrypted = ''.join([chr(ord(a) ^ ord(b)) for a, b in zip(message, secret)])
decrypted = ''.join([chr(ord(a) ^ ord(b)) for a, b in zip(encrypted, secret)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment