Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there anyway to detect that a cipher is encrypted with ROT13 Or Base64 without decrypting it using the algorithm and check that the result means (works)? I mean does an algorithm exists that test the cipher and tell YES it is ROT13/Base64 (or NO it isn't)?


share|improve this question
Neither ROT13 nor Base64 fit a modern definition of cipher, for neither have a key. At best, these are codes. – fgrieu Nov 20 '12 at 9:40
What's wrong with just decrypting it and checking that the result looks reasonable? That's a perfectly valid method of detecting those schemes. In particular, that is one example of an algorithm that tests the ciphertext and tells YES if it is ROT13/Base64 (or NO if it isn't). – D.W. Nov 20 '12 at 19:42
@fgrieu: technically, ROT13 is a cypher, albeit a very weak one. It is a Caesar cypher with a key (=shift) of 13. The problem being that the key is not really a secret. – rossum Nov 22 '12 at 15:48
Both of them are encoding methods. Not an encryption. – Pavel Ognev Nov 23 '12 at 6:54
up vote 4 down vote accepted

Without using ROT13 explicitly, it can be done. You can draw up a frequency histogram of the text, and then shift it 13 characters left (or right). If it lines up to give the average English frequency distribution, it's likely this is ROT13 material. This will only work well if you have a large enough sample, obviously.

You should be able to do roughly the same thing with Base64, since it too preserves frequencies to some extent (though in a less obvious way, as the encoding works at the bit level, not on each character)

Though for Base64 a more intelligent approach is to just decode the whole thing and check that it looks like english (or whatever format you expect, really) either by frequency analysis or another method. It would be much faster and easier, but according to your question this is not a valid approach, so...

Nitpick: neither ROT13 nor Base64 use a cryptographic key, so they are not ciphers, but encodings (at least Base64 is - ROT13 tries to be a cipher, and could be called one, I suppose, but it's not technically correct).

share|improve this answer
Please tell me what encoding means exactly? Is there any relation between it and encryption? – H M Apr 26 '13 at 4:55
@HM Encoding simply means to "write something differently", either to save space, increase readability, or some other purpose. Encryption means "encoding something with the clear purpose of preventing unauthorized entities to read the information". So encryption is a specific form of encoding, but encoding is not encryption. But in general we do not like to call encryption encoding because it is too broad a term. – Thomas Apr 26 '13 at 8:11
Thanks! Excellent explanation. Can a hash (e.g. md5) be considered a specific form of encoding too? – H M Apr 28 '13 at 16:40
Not really, in my opinion. Encoding needs to be reversible, you need to be able to "decode" the encoded data back to the original data. But I suppose it could be argued that non-reversible processes could be called "encoding" in a meaningful sense (for instance, lossy compression). – Thomas May 1 '13 at 6:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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