I occasionally include functional code (usually C99) in answers, as an argument or illustration of my point.

What should be the limits to that ?

For example, I'm taking this comment as a challenge, and if that was a question (on the tune of: how much code is needed for fast verification of signature on a resource-constrained CPU?), I'd be mildly tempted to write RSASSA-PKCS1-v1_5 or Rabin signature verification code, optimized for size, complete with modular exponentiation and SHA-256, to prove that it can be done in portable C99 under 4 kByte of code + constants + public key and 1 kByte of RAM, while still leaving anything ECC-based in the dust on speed.

  • 1
    Intuitively I'd say "we are neither SO nor PPCG.SE so code should be used the same as figures: To illustrate a point and not be the answer and same as with figures, few people tend to actually look at the overly complex ones". – SEJPM Jul 21 at 8:55
  • If pseudocode would be appropriate, then real code in some common language is probably okay. Sometimes code is less ambiguous or more accessible than prose, formulas, or pseudocode. – Future Security Jul 21 at 18:11

If it compliments an answer, code is fine.

But you don't want to end up posting a code-only answer or a short answer with a wall-of-code (100 lines +) appended as you'ld be risking users to mistake Crypto.SE for Stackoverflow and sooner or later you might end up with nasty things like having to answer code-related questions in the comments, or fulfilling sourcecode requests, etc.

So, it's a bit about the balance between actual answer and supplemental sourcecode.

For anything that tips the scale heavy towards sourcecode, there's a sneaky way to work around the wall-of-code problem. When a Q, A, or comment triggers you to actually write a full-fledged implementation with all the bells and whistles (like you describe in your example), you could push your project to something like Github or your own website (if you have one) and simply link to your lengthy sourcecode project in your answer/comment as a "bonus" or "proof of concept" kinda thing. When choosing that path, the sky is the limit and the only no-go would probably be a link-only answer which only points to your code. (OTOH, knowing you as someone who doesn't spare words when answering Qs, I doubt I'll ever see you post a link-only answer.)

You must log in to answer this question.

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