public void Crupt()//object a) { //cruptum tmp = (cruptum)a; //List<string> text = new List<string>(); //for (int i = 0; i < tmp.text.Length; i+=tmp.key.Length) //{ // char[] textTMP = new char[tmp.key.Length]; // tmp.text.CopyTo(i, textTMP, 0, tmp.key.Length); // text.Add(textTMP.ToString()); //} //foreach (var item in text) //{ // crupto_text += (string)(item.ToString() ^ tmp.key); //} string crupto_text = new string(text.Select((c, index) => (char)(c ^ key[index % key.Length])).ToArray()); string decrupt_tect = new string(crupto_text.Select((c, index) => (char)(c ^ key[index % key.Length])).ToArray()); Console.WriteLine(crupto_text); //return crupto_text; string[] result = { $"text -> {text}", $"key -> {key}", $"encrupt text -> {crupto_text}", $"decrupt text -> {decrupt_tect}" }; using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\shpak_d\Documents\1.txt")) { foreach (string line in result) { file.WriteLine(line); } } callback?.Invoke("Complete"); }
// The thread procedure performs the task, such as // formatting and printing a document, and then invokes // the callback delegate with the number of lines printed. public void ThreadProc() { int counter; for (counter = 0; counter < 5; counter++) { Debug.WriteLine( $"Report processing iteration #{counter}."); } Debug.WriteLine( $"{counter}: {_boilerplate} {_numberValue}."); _callback?.Invoke(counter); }