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

This question already has an answer here:

I have a (long) text in two versions, encrypted and plaintext. I think it was encrypted using a substitution cipher method (I'm pretty sure, indeed).

I'm not good in this matter, I know little about it, but I would know if there's a way to know the function/secret used for encrypt that text. I'm ready to study, anyway :)

share|improve this question

marked as duplicate by woliveirajr, rath, mikeazo Jul 25 '13 at 16:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

I can't detect anything that might be regarded to be a question… what are you trying to ask? – e-sushi Jul 11 '13 at 20:48
In short: No. Run a frequency analysis if you believe it's a substitution cipher, the relevant wikipedia page should be enough to get you started. If there was an easy way to know the secret (I assume you mean the key), it wouldn't be called a secret. – rath Jul 24 '13 at 19:48
Your question is basically a duplicate of other questions here, e.g.,… – mikeazo Jul 25 '13 at 16:39

If it is a long text and you are sure it is a substitution cipher there are a lot of statistical methods to find the key. Statistical methods rely on the frequency at which alphabets occur in a language. Not just single alphabets but even pairs. For eg in the english alphabet 'E' is the most frequent alphabet followed by 'T' and 'A'. Also some characters such as 'CH' 'QU' 'TH' are found together frequently. All these results can be used to identify the key for the substitution cipher. The longer the text you have the easier it is to identify these patterns. There are quite a few tools online that help you analyse these patterns. Also as mentioned in another answer if you already have parts of the plain text too it is trivial to find the mapping of those characters.

Detailed explanation:

simple explanation:

share|improve this answer
Please, don't just post links. Your answer should explain it, not a link to another site. Why? Because the linked content may vanish any time and then your answer would be useless. – e-sushi Jul 12 '13 at 12:58
thanks. Made the changes. – Ruchir Patwa Jul 15 '13 at 20:52

Typically, your key in a substitution cipher is just a mapping between a letter in plaintext and a letter in the ciphertext. That is, something like "A" => "B", which would mean that every instance of the letter A in the plaintext will be changed to a B in the ciphertext. Going the other way (B=>A) is the decryption.

If you know a single plaintext and ciphertext, you can figure out the mapping by just looking at each letter in the plaintext and seeing what it maps to in the ciphertext. Using this mapping for each character, you can now encrypt and decrypt any other message you want.

share|improve this answer

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