I am trying to make a program which can help you to break a cipher text without knowing the plain text and the key.
I want probable plain text at the output which gives the closest statistical values and a set of probable candidates keys
I started doing the frequency analysis,completed it. It helped me in telling the occurrence of each alphabet, but I have no idea how will I generate keys from that.
class Program
{
static void Main()
{
// Array to store frequencies.
int[] c = new int[(int)char.MaxValue];
// Read entire text file.
string s = File.ReadAllText("text.txt");
// Iterate over each character.
foreach (char t in s)
{
// Increment table.
c[(int)t]++;
}
// Write all letters found.
for (int i = 0; i < (int)char.MaxValue; i++)
{
if (c[i] > 0 &&
char.IsLetterOrDigit((char)i))
{
Console.WriteLine("Letter: {0} Frequency: {1}",
(char)i,
c[i]);
}
}
}
}