Skip to content

Instantly share code, notes, and snippets.

@lttn1204
Created April 9, 2021 06:25
Show Gist options
  • Save lttn1204/69c33ff19596e2b128b9ea2d35847032 to your computer and use it in GitHub Desktop.
Save lttn1204/69c33ff19596e2b128b9ea2d35847032 to your computer and use it in GitHub Desktop.
import os
import zlib
def keystream():
key = os.urandom(2)
index = 0
while 1:
index+=1
if index >= len(key):
key += zlib.crc32(key).to_bytes(4,'big')
yield key[index]
ciphertext = []
with open("plain","rb") as f:
plain = f.read()
assert b"actf{" in plain
k = keystream()
for i in plain:
ciphertext.append(i ^ next(k))
with open("enc","wb") as g:
g.write(bytes(ciphertext))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment