making an illegal prime number

have you ever heard about illegal numbers?

you see, some computer data is illegal. the obvious example is copyright infringement; any data which was obtained by infringing copyright is illegal to have. this makes sense in theory… but because all computer data is just numbers, it means that illegal computer data is a number that happens to be illegal to know.

a related concept is an illegal prime number. if you somehow encode illegal data into a prime number, that prime number becomes illegal. but that has to be hard, right?

well, not really.

many file formats contain headers that have all the important information about the file. and some file formats have a header that says how big the file is. any extra data added to the end will simply be ignored, since it's not truly supposed to be a part of the file. the ZIP format happens to do this, which is convenient, since it's supported on just about every platform and can contain any files you like.

because of this, you can encode any data you'd like as a prime number. simply ZIP it up, and then shove bytes on the end until it turns into a prime number!1

the reason i went on this adventure was because of the controversy surrounding Dolphin's use of the Wii's common key2 in their code. i though it would be fun to encode it as a prime number. here's what that number is, by the way:



pretty neat, huh? you can download it as a zip file here if you'd like to check for yourself. and if you're curious how i generated it, here's the Python code I wrote:
import sympy as sp

with open("", mode="rb") as file:
	fileContents = bytearray(
	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]
	print("prime detected")
	with open("", "wb") as outFile:

1. there are probably better ways to do this, but i am not good at math, and brute-forcing works well enough for small files.

2. all Wii games are encrypted using a common key, which is shared by all consoles. one could reasonably just decrypt the games while ripping them to avoid this problem entirely, but for some reason Dolphin never did this.

topics annoyance

your browser is stalking you.

this website is best viewed in browsers which do not implement the Topics API, such as Firefox.