Skip to content

Instantly share code, notes, and snippets.

@ay0ks
Last active March 25, 2025 10:30
Show Gist options
  • Save ay0ks/d0bfc2fe23b7fd473faca14398c7e96e to your computer and use it in GitHub Desktop.
Save ay0ks/d0bfc2fe23b7fd473faca14398c7e96e to your computer and use it in GitHub Desktop.
PoC One-Time Pad encryption in Python
otp = lambda *args: [a ^ b for a, b in zip(*args)]
data = b"Hello World!"
# One-Time Pad encryption usually requires the encryption key to be at least the same length as
# the input data, or longer.
key = __import__("os").urandom(len(data))
print(otp(data, key))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment