0
$\begingroup$

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)?

Thanks

$\endgroup$
4
  • 1
    $\begingroup$ Neither ROT13 nor Base64 fit a modern definition of cipher, for neither have a key. At best, these are codes. $\endgroup$
    – fgrieu
    Nov 20 '12 at 9:40
  • $\begingroup$ 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). $\endgroup$
    – D.W.
    Nov 20 '12 at 19:42
  • 1
    $\begingroup$ @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. $\endgroup$
    – rossum
    Nov 22 '12 at 15:48
  • $\begingroup$ Both of them are encoding methods. Not an encryption. $\endgroup$ Nov 23 '12 at 6:54
5
$\begingroup$

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).

$\endgroup$
4
  • $\begingroup$ Please tell me what encoding means exactly? Is there any relation between it and encryption? $\endgroup$
    – H M
    Apr 26 '13 at 4:55
  • 2
    $\begingroup$ @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. $\endgroup$
    – Thomas
    Apr 26 '13 at 8:11
  • $\begingroup$ Thanks! Excellent explanation. Can a hash (e.g. md5) be considered a specific form of encoding too? $\endgroup$
    – H M
    Apr 28 '13 at 16:40
  • 2
    $\begingroup$ 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). $\endgroup$
    – Thomas
    May 1 '13 at 6:51

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.