Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: encryption (chi-squared test)

by gumby (Scribe)
on Jun 20, 2002 at 12:40 UTC ( #175986=note: print w/ replies, xml ) Need Help??

in reply to encryption

An alternative, of course, is to use a statistical method: use the chi-squared test (see Mathworld).

Let F_a(x) be the frequency of some letter, x, in you're alphabet, and let F_m(x) be the frequency of some letter, x, in the message. Now, for all 0 <= s <= 25 calculate for each letter, x, in your alphabet the sum of the squares of F_m((x + s)(mod 26)) / F_a(x). The value of s for which this obtains a minimum is the shift used to encipher the message.

Comment on Re: encryption (chi-squared test)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://175986]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2015-12-01 00:04 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (788 votes), past polls