This answer to the question Can numbers be illegal? makes a good argument, and AFAIK it comports with the law. It follows other answers in observing that any piece of information can be encoded by numbers. Yes, there are pieces of information that are illegal to possess – e.g., child pornography, stolen intellectual property, financial numbers intended to commit theft or fraud. But it asserts, without reference to law, that if you don't know that application of the number your possession can't be illegal. So it begs the following two interesting questions:

Do information possession crimes always require mens rea?

I can't think of a circumstance in which one could be charged for a crime for possession without knowledge of the significance of the number. I know this is a "prove a negative" problem, but if anyone knows of a possession crime that does not require a guilty mind that would be noteworthy.

Is there a safe harbor for possession of an "illegal" number?

If you are found in possession of stolen property, even if you lack mens rea, you are not allowed to keep it. If you are found in possession of stolen data can you keep it if it also represents something you can possess?

E.g., if an encrypted version of your password database also happens to produce a JPEG-encoded image of child pornography, can you keep it if you show that you have a code that transforms it into information that is not child pornography?

  • So I certainly do not know a legal statute for this, but I would expect it is very dependent on the entropy of the number and very dependent on other circumstances. I can, for instance, always convert a JPEG of something illicit into "a stream of random numbers for my monte-carlo simulation" with nothing more than a hash function. I would expect the law would account for this. Likewise, I'm sure there's some numbers we aren't "supposed" to know buried in the digits of pi, but it would be clear from the data that we "intended" to know pi, not the secret number.
    – Cort Ammon
    May 6, 2016 at 23:26
  • 1
    "happens to produce": for any two files of the same length, there is at least one process that can produce one from the other, namely, encryption by one-time pad. This can be extended to files of different lengths. So pretty much any file can "happen to produce" pretty much any other.
    – phoog
    Jun 6, 2016 at 5:19

3 Answers 3


Intent would greatly factor into the case. As mentioned, possession of child pornography is illegal. There was a case, where a man had inadvertently downloaded such images. In the case, it was shown that there was sufficient evidence that it was accidental and without his knowledge. Presumably, if you by happenstance created an identical code through encryption/compiling, there would be a lack of evidence of intent or evidence of your intended use.

For example, your stored password manager file happens to store data identical to an illegal image. The password manager output is provable and repeatable to show that it was simply circumstantial. If you have hundreds of such outputs that all "just happen to be illicit images" you would probably fall on the wrong side of reasonable doubt. As to whether you can keep the data, the programmers for the password manager would probably update their system to modify the output to avoid bad press.

The general idea is that the "illegal number" is so incredibly specific that accidental cases are very unlikely to occur, and if it did, that there would be forensic evidence indicating intent and use.


Most jurisdictions have adopted codified rather than common law crimes - the concept of mens rea is therefore largely irrelevant. A crimes act will define what constitutes the crime and what the permissible defences are. Therefore you need to go to the statute that makes the possession illegal and find out what it says you can raise as a defence.


I want to give a mathematical answer rather than a legal answer. The legal experts may want to comment about what a judge would think about this, and Nicholas Psoras's answer already hints at it, but I can promise you this much: if they find it necessary, the prosecution will put on the stand an expert witness with impeccable credentials who will testify to what I write below, and the defence is not going to be able to find anyone reputable to testify to the opposite.

You are not going to get an illegal JPEG by chance. Of course, art is subjective, and a field of static (like a Jackson Pollock painting) can be interpreted as a pornographic image if one is so inclined, but a photorealistic depiction will not arise by chance. To be sure, it's not mathematically impossible, but it's far beyond any reasonable doubt; the qualified expert will be able to quantify how improbable we're talking about here better than I can, but we're not talking about one in a million, we're talking about one in a trillion trillion trillion.

As phoog commented under the original question, there's always a code that will turn your illegal file into something innocuous (or turn something innocuous into something illegal). But the information has to reside somewhere, and if you have a cryptography program that turns the text of Moby-Dick into an illegal image, then that program did not arise by chance; it was designed to do this. (In fact, the program should itself be illegal; it's really the image in an encrypted form, to which the text of Moby-Dick is merely the key.)

The sort of illegal number that comes up in cryptography (and in the Wikipedia article that inspired the cited question) is much shorter, although still not likely to arise by chance. Some of the things mentioned in the answers to that question, such as passwords and social-security numbers, are starting to get downright reasonable. (Getting a specific person's SSN by randomly picking 9 digits is still a one-in-a-billion long shot, but if you're writing down random numbers all day, then it can certainly happen.) But you don't seem to be asking about that, but rather about something that would be illegal in and of itself, without context. That requires all of the relevant information to be packed into that one number.

In short, if your defence is that the illegal image (assuming that we are talking about something like a photograph and not something like a password) appeared on your computer by chance as the result of harmless computer activity, then your defence is a lie (or at best an honest mistake about what was done with your computer). It may be interesting to know whether it would be a legally valid defence if true; after all, people have managed to fool juries (and judges) with lies before, and maybe the expert witness won't be believed. But the defence will be factually false.

  • Say Eve takes something bad, and uses some sort of trick to generate something reasonable looking which she sends to Bob. Is Bob in trouble? If FILE decrypts to both BADFILE and GOODFILE using different keys can I still use GOODFILE? and is possessing FILE dangerous?
    – user4460
    Mar 23, 2018 at 20:23
  • @notstoreboughtdirt : Your first question is a fair one, but it must surely have come up in court before. Eve sends Bob an encrypted illegal file, Bob has no idea what it is, is Bob in trouble? I hope not, but that's beyond my competence as a mathematician to say; ask a lawyer. Mar 24, 2018 at 5:00
  • @notstoreboughtdirt : For your second question: If BADFILE is around the size of a child porn JPEG, then FILE is not going to decrypt to both of them using different keys by chance; it must be carefully set up that way. You could do this so that GOODFILE is perfectly harmless, in that you can't recover BADFILE from GOODFILE, at least not without using something that amounts to the contents of BADFILE in itself. But if GOODFILE has the contents of BADFILE hidden within it (a cute kitten with child porn hidden in the alpha channel), then it's not really the good file that you thought it was. Mar 24, 2018 at 5:00
  • 1
    Of course, I don't really know what a judge or jury will find legal or illegal, but at least you should be able to find an expert witness to explain that GOODFILE does or does not contain the contents of BADFILE. (At least, assuming that they can tell; the facts could be in dispute if the forensics is imperfect and the contents might be cleverly hidden.) The point of my answer is that, contrary to the last paragraph of the question, it's not realistic that GOODFILE will somehow contain BADFILE by pure bad luck. Mar 24, 2018 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.