Created
April 9, 2021 06:25
-
-
Save lttn1204/69c33ff19596e2b128b9ea2d35847032 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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