Created
June 7, 2023 04:30
-
-
Save mothdotmonster/6ac9d8d022ac1a6d6aabc9c1c7abbb75 to your computer and use it in GitHub Desktop.
turn a zip file into a prime number
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 sympy as sp | |
fileName = "file.zip" | |
with open(fileName, mode="rb") as file: | |
fileContents = bytearray(file.read()) | |
fileContents.append(255) | |
while not sp.isprime(int.from_bytes(fileContents)): | |
if (int.from_bytes(fileContents[-1:]) != 0): | |
print("bruteforcing " + str(int.from_bytes(fileContents[-1:]))) | |
fileContents[-1:] = [int.from_bytes(fileContents[-1:]) - 1] | |
else: | |
print("appending") | |
fileContents.append(255) | |
print("prime detected") | |
print(int.from_bytes(fileContents)) | |
with open("file-prime.zip", "wb") as outFile: | |
outFile.write(fileContents) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is very slow, don't use it on anything more than a couple bytes