static void Main(string[] args) { String text = ""; Alphabet alphabet = new Alphabet(); using (StreamReader sr = new StreamReader("D:/alf.txt")) { text = (sr.ReadToEnd()); text = text.Replace(" ", ""); Console.WriteLine(text); } String text2 = ""; Alphabet alphabet2 = new Alphabet(); using (StreamReader sr = new StreamReader("D:/alf2.txt")) { text2 = (sr.ReadToEnd()); text2 = text.Replace(" ", ""); Console.WriteLine(text2); } Console.WriteLine("Entropy: " + alphabet.Entropy(text, alphabet.Cyrillic)); Console.WriteLine("Entropy: " + alphabet.Entropy(text, alphabet.Latin)); alphabet.BuildExel(alphabet.Latin); Console.WriteLine("Entropy: " + alphabet.Entropy(text, alphabet.Binary)); Console.WriteLine("Infor: " + alphabet.kolInf(alphabet2.Entropy(text2, alphabet2.Latin), text2.Length)); using (StreamWriter sw = new StreamWriter("D:/byt.txt", false, System.Text.Encoding.Default)) { sw.WriteLine(alphabet.getBytes(alphabet.GetASCII("pakholkoalyonastepanovna"))); } using (StreamReader sr = new StreamReader("D:/byt.txt")) { text = (sr.ReadToEnd()); text = text.Replace(" ", ""); } Console.WriteLine("Infor: " + alphabet.kolInf(alphabet.Entropy(text, alphabet.Binary), text.Length)); Console.WriteLine("Infor: ERROR 0.1 " + alphabet.EfectEntropy(0.1)); Console.WriteLine("Infor: ERROR 0.5 " + alphabet.EfectEntropy(0.5)); Console.WriteLine("Infor: ERROR 1 " + alphabet.EfectEntropy(1)); Console.ReadKey(); }
static void Main(string[] args) { //949 — Korean, 1253 — Greek, 65001 (UTF-8) //Console.WriteLine("안녕하세요"); Console.OutputEncoding = Encoding.Unicode; String text = ""; Alphabet alphabet = new Alphabet(); using (StreamReader sr = new StreamReader("korean.txt")) { text = (sr.ReadToEnd()); text = text.Replace(" ", ""); } using (StreamWriter sw = new StreamWriter("otvet.txt", false, System.Text.Encoding.Unicode)) { sw.WriteLine(text); } double EntKor = alphabet.Entropy(text, alphabet.Korean); alphabet.BuildGistogram(alphabet.Korean); double EntBin = alphabet.Entropy(text, alphabet.Binary); using (StreamWriter sw = new StreamWriter("otvet.txt", true, System.Text.Encoding.Unicode)) { sw.WriteLine(); sw.WriteLine("Entropy korean: " + EntKor); ///sw.WriteLine("Entropy cyrillic: " + alphabet.Entropy(text, alphabet.Cyrillic)); ///sw.WriteLine("Entropy latin: " + alphabet.Entropy(text, alphabet.Latin)); sw.WriteLine("Entropy binary: " + EntBin); sw.WriteLine("Infor korean: " + alphabet.kolInf(EntKor, text.Length)); } using (StreamWriter sw = new StreamWriter("byt.txt", false, System.Text.Encoding.Default)) { sw.WriteLine(alphabet.GetBytes("ㅊㅣㅅㅌㅑㄱㅓㅘ ㅠㄹㅣㅑ")); } using (StreamReader sr = new StreamReader("byt.txt")) { text = (sr.ReadToEnd()); text = text.Replace(" ", ""); } using (StreamWriter sw = new StreamWriter("Infor.txt", false, System.Text.Encoding.Unicode)) { sw.WriteLine("Infor binary: " + alphabet.kolInf(alphabet.Entropy(text, alphabet.Binary), text.Length)); sw.WriteLine("Effect Entropy (ERROR 0.1) : " + alphabet.EfectEntropy(0.1)); sw.WriteLine("Effect Entropy (ERROR 0.5) : " + alphabet.EfectEntropy(0.5)); sw.WriteLine("Effect Entropy (ERROR 1) : " + alphabet.EfectEntropy(1)); ///P ошибочн передачи единич бита } Console.WriteLine("Выполнено успешно!"); Console.ReadKey(); }