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

Neither ROT13 nor Base64 fit a modern definition of cipher, for neither have a key. At best, these are codes.
–
fgrieuNov 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

1

@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.
–
rossumNov 22 '12 at 15:48

Both of them are encoding methods. Not an encryption.
–
Pavel OgnevNov 23 '12 at 6:54

1 Answer
1

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

Please tell me what encoding means exactly? Is there any relation between it and encryption?
–
H MApr 26 '13 at 4:55

2

@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.
–
ThomasApr 26 '13 at 8:11

Thanks! Excellent explanation. Can a hash (e.g. md5) be considered a specific form of encoding too?
–
H MApr 28 '13 at 16:40

2

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).
–
ThomasMay 1 '13 at 6:51