According to @Maeher, we are not allowed to illustrate questions on crypto.stackexchange.com with executable code—such questions are permissible only on stackoverflow.com:


Squeamish Ossifrage: Are we forbidden from illustrating questions with executable code?

Maeher: @SqueamishOssifrage As I understand the scope of the site, yes.

Executable code that demonstrates a particular computation is sometimes the clearest way to phrase a computational question. Are we allowed to use it to illustrate questions about cryptographic algorithms, or must any questions with executable code be migrated to stackoverflow.com?

To be clear, I am not asking about questions on debugging software, about API usage, about higher-level security assessments of systems, about coding practices, about development tools, about program organization, etc.—I'm only asking about questions on cryptographic algorithms that are illustrated using executable code.

I am also not asking about any particular languages or libraries—I'm only asking whether the mere executability of code used for illustration is grounds for migrating or closing a question. Obviously languages like Unlambda are not useful for illustration, obviously it is not helpful to copy & paste an entire Java class library to point out a question about a single line, obviously this is not an OpenSSL help site (a deityforsaken place where questions go to meet horrible deaths)—and obviously questions illustrated by Unlambda or Java class library copypasta or questions about how to use OpenSSL could rightly be closed for being unclear or too broad or be migrated to stackoverflow.com.

I don't have any questions, but here are some answers I have written with code fragments that, it seems to me, could plausibly have appeared in questions too; these are principally about algorithms and not about API usage, development tools, program organization, or anything that seems to be the domain of stackoverflow.com:

Are these all forbidden from crypto.stackexchange.com?


4 Answers 4


Yes, you are allowed to post code to illustrate a question. Preferably this code is easy to understand. Pseudo-code could be better for this, as any API/language has hard to understand constructs to the uninitiated (I presume that you mean an actual programming language when talking about "executable" code). Preferably the question does not fully rely on the programming code itself, using textual description or of course math to describe the problem.

However, if it is likely that the code itself is the reason why an implementation creates invalid values then it should definitely be posted on StackOverflow. If the code fails to execute correctly because of a possible mistake in understanding the scheme or algorithm then the question should pinpoint the likely culprit and ask a specific question on it.

Cryptography has a very accomplished user base that is more likely to get some issues fixed. However, if we allow too many implementation specific issues to post here we will get flooded by them, resulting in a stream of questions of the same level of quality that the cryptography / encryption tags on StackOverflow currently generate - so this is not a workable proposition.


Are we allowed to use it to illustrate questions about cryptographic algorithms, or must any questions with executable code be migrated to stackoverflow.com?

Answers are most definitely allowed to use compilable code, just like they are allowed to use figures to illustrate. Of course it can be questionnable whether code is the right illustration in any given situation or whether something like pesudo-code would provide a better illustration.

As for Questions there the situation is a bit more complicated. If the question is about debugging a piece of (crypto-)code, it most definitely is off-topic here. If the question asks about the security of a piece of code, it is also off-topic. If the question is illustrating the problem using code, but also asks it to be (somewhat) understandable without code, it should be fine (subject to the other previous rulings we have). If it asks a question that is not understandable without the code, then it (most likely) is about the code and thus (most likely) off-topic.

  • $\begingroup$ I am specifically asking about using executable code to illustrate a question about a cryptographic algorithm, not about security assessment of the code (especially not about security assessment beyond the cryptography it illustrates), not about API usage, not about debugging. $\endgroup$ May 17, 2019 at 15:41
  • $\begingroup$ SEJPM clearly tries to define some boundaries here for (executable) code, and you're naming two that fall outside that boundary, yes. I don't see those boundaries being explicitly defined in your question. $\endgroup$
    – Maarten Bodewes Mod
    May 17, 2019 at 15:48

If it could be turned into pseudocode without invalidating the question, it should be on-topic. The main reason for someone to use a real language is either because that is the language they are used to, or because it's easier for them to post existing code than translate it. If it must be in a specific language to be a valid question, then it is off-topic for this site. Of course, a question may still be low-quality or hard to understand if it involves a heavy amount of code, and if the OP does not make any effort to clean their code and strip the irrelevant parts, then we can vote to close it for other reasons.

For example, if code is posted which does not work because OP did not know that a given arithmetic operation had to be done in a specific field, then it should be on-topic. If, on the other hand, it does not work because a null pointer is being dereferenced, then it is clearly off-topic and should be closed. A simple rule of thumb would be that compiler errors or crashes/exceptions are always off-topic, but generated output that does not match official test vectors for example is not necessarily off-topic.

In edge cases, a given question's topicality might depend on OP's intentions. A program to generate an RC4 keystream but which is not correct because OP didn't know that he had to use char if he wanted 8-bit operations and mistakenly used short would be off-topic, but if the problem was because OP thought that RC4 operations were done modulo 216 and intentionally used that datatype, then it would be on-topic. In such an edge case, it would be necessary to ask OP to rewrite their code in pseudocode.


My view on the matter is that there are two possibilities:

  1. Code in some programming language is necessary for the question to make sense. In that case the question is off-topic here.
  2. Code in some programming language is not necessary for the question to make sense. In that case the question could be vastly improved by replacing the code with an abstract description.

None of Squeamish Ossifrage are of course examples, given that they are not questions. But then again, if a question can only be answered using code, it should be off-topic. Otherwise an abstract description would benefit readability greatly.

  • $\begingroup$ Does psuedocode count as an "abstract description"? I am not convinced that abstraction benefits readability greatly - It can easily make a concept much more difficult to understand than a concrete example. $\endgroup$
    – Ella Rose
    May 18, 2019 at 13:37
  • $\begingroup$ Why is it preferable to take a clear fragment of code that works and runs and replace it by one that doesn't work and requires a human familiar with vague sociological conventions to guess what it even means? Why is this a criterion? (Obviously working code can sometimes have piles of administrivia spread across Java class files and hoops to jump through, but those barriers to exposition are not what I'm asking about: I'm asking about using executability itself as a criterion for whether code is an admissible way to illustrate a computational idea.) $\endgroup$ May 18, 2019 at 15:07
  • 1
    $\begingroup$ And, let's take this criterion at face value. Suppose you wrote an ‘abstract description’. Suppose, then, that someone did guess what you meant, and wrote an interpreter for the language that seems to execute the algorithm as you ‘abstractly’ described it. Would that turn the ‘abstract description’ from a good, admissible exposition into a bad, inadmissible exposition because it is now executable? $\endgroup$ May 18, 2019 at 15:11
  • 2
    $\begingroup$ What if I took working Python code, and inserted a bug in it so that it won't even compile? Then would it be an ‘abstract description’, because you have to guess what I meant and can't ask a machine to execute it—would that satisfy your criterion? $\endgroup$ May 18, 2019 at 15:28
  • $\begingroup$ Well, I for one am not a computer. So the fact that there exists an interpreter for your obscure syntax is not helpful in the slightest. And to turn your asinine argument around: what if I wrote an interpreter that that interprets your python code differently. Suddenly the execution of your precious code is no longer uniquely defined. The horror! $\endgroup$
    – Maeher
    May 19, 2019 at 12:54
  • $\begingroup$ Naturally, this whole question is completely pointless. I mentioned my opinion about the interpretation of the sites scope. My opinion has no bearing whatsoever on the sites rules. If you want to turn this site into a QA about programming minutiae, that's fine. I'll find somewhere else to spend my time when and if that happens. $\endgroup$
    – Maeher
    May 19, 2019 at 12:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .