|
@@ -21,8 +21,6 @@ namespace Encrypter
|
|
public partial class MainWindow : Window
|
|
public partial class MainWindow : Window
|
|
{
|
|
{
|
|
Encoding ascii = Encoding.ASCII;
|
|
Encoding ascii = Encoding.ASCII;
|
|
- Encoding unicode = Encoding.Unicode;
|
|
|
|
-
|
|
|
|
|
|
|
|
public MainWindow()
|
|
public MainWindow()
|
|
{
|
|
{
|
|
@@ -31,50 +29,41 @@ namespace Encrypter
|
|
private void sposob1_encrypt(object sender, RoutedEventArgs e)
|
|
private void sposob1_encrypt(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
|
|
|
|
- Dictionary<char, int> dictionarys = sposob1_input.Text.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
|
|
|
|
- int uniqueSymbCount = dictionarys.Count();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //char[] symb = dictionarys.Select(q => q.Key).ToArray();
|
|
|
|
|
|
+ string input = sposob1_input.Text, output = "";
|
|
|
|
|
|
- //char[] newSymb = new char[uniqueSymbCount];
|
|
|
|
-
|
|
|
|
- //foreach (KeyValuePair<char, int> keyValuePair in dictionarys)
|
|
|
|
- //{
|
|
|
|
- // //keyValuePair.Value;
|
|
|
|
- // MessageBox.Show($"{keyValuePair.Key} : {keyValuePair.Value}");
|
|
|
|
- //}
|
|
|
|
- //byte smb = 100;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //for (int i = 0; i < newSymb.Length; i++)
|
|
|
|
- //{
|
|
|
|
- // newSymb[i] = Convert.ToChar(smb);
|
|
|
|
- // smb++;
|
|
|
|
- // MessageBox.Show(newSymb[i].ToString());
|
|
|
|
- //}
|
|
|
|
|
|
+ Dictionary<char, int> dictionarys = input.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
|
|
|
|
+ int uniqueSymbCount = dictionarys.Count();
|
|
|
|
|
|
- //foreach (char c in sposob1_input.Text)
|
|
|
|
- //{
|
|
|
|
- // for(int i = 0;i<)
|
|
|
|
- //}
|
|
|
|
|
|
+ Byte[] encodedBytes = ascii.GetBytes(input);
|
|
|
|
+ foreach (Byte b in encodedBytes)
|
|
|
|
+ output += $"{b + Convert.ToInt32(dictionarys.Where(item => item.Key == Convert.ToChar(b)).Select(item => item.Value).FirstOrDefault())}%";
|
|
|
|
+ sposob1_output.Text = output;
|
|
|
|
|
|
- //foreach (char c in symb)
|
|
|
|
- // MessageBox.Show(c.ToString());
|
|
|
|
}
|
|
}
|
|
private void sposob1_decrypt(object sender, RoutedEventArgs e)
|
|
private void sposob1_decrypt(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
|
|
+ //not working
|
|
|
|
+ string input = sposob1_input2.Text, output = "";
|
|
|
|
|
|
|
|
+ Dictionary<char, int> dictionarys = input.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
|
|
|
|
+ int uniqueSymbCount = dictionarys.Count();
|
|
|
|
+ int pos = 0;
|
|
|
|
+
|
|
|
|
+ while (input.IndexOf('%') != -1)
|
|
|
|
+ {
|
|
|
|
+ byte temp = Convert.ToByte(Convert.ToInt32(input.Substring(0, input.IndexOf('%'))) - Convert.ToInt32(dictionarys.Where(item => item.Key == Convert.ToChar(b)).Select(item => item.Value).FirstOrDefault()));
|
|
|
|
+ pos++;
|
|
|
|
+ output += Convert.ToChar(temp);
|
|
|
|
+ input = input.Remove(0, input.IndexOf('%') + 1);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ sposob1_output2.Text = output;
|
|
}
|
|
}
|
|
private void sposob2_encrypt(object sender, RoutedEventArgs e)
|
|
private void sposob2_encrypt(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
string input = sposob2_input.Text, output = "";
|
|
string input = sposob2_input.Text, output = "";
|
|
int pos = 0;
|
|
int pos = 0;
|
|
|
|
+
|
|
Byte[] encodedBytes = ascii.GetBytes(input);
|
|
Byte[] encodedBytes = ascii.GetBytes(input);
|
|
foreach (Byte b in encodedBytes)
|
|
foreach (Byte b in encodedBytes)
|
|
{
|
|
{
|
|
@@ -87,6 +76,7 @@ namespace Encrypter
|
|
{
|
|
{
|
|
string input = sposob2_input2.Text, output = "";
|
|
string input = sposob2_input2.Text, output = "";
|
|
int pos = 0;
|
|
int pos = 0;
|
|
|
|
+
|
|
while (input.IndexOf('%') != -1)
|
|
while (input.IndexOf('%') != -1)
|
|
{
|
|
{
|
|
byte temp = Convert.ToByte(Convert.ToInt32(input.Substring(0, input.IndexOf('%'))) - pos);
|
|
byte temp = Convert.ToByte(Convert.ToInt32(input.Substring(0, input.IndexOf('%'))) - pos);
|
|
@@ -99,6 +89,7 @@ namespace Encrypter
|
|
private void sposob3_encrypt(object sender, RoutedEventArgs e)
|
|
private void sposob3_encrypt(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
string input = sposob3_input.Text, output = "";
|
|
string input = sposob3_input.Text, output = "";
|
|
|
|
+
|
|
Byte[] encodedBytes = ascii.GetBytes(input);
|
|
Byte[] encodedBytes = ascii.GetBytes(input);
|
|
foreach (Byte b in encodedBytes)
|
|
foreach (Byte b in encodedBytes)
|
|
output += $"{b + input.Length}%{input.Length}^?";
|
|
output += $"{b + input.Length}%{input.Length}^?";
|
|
@@ -106,9 +97,9 @@ namespace Encrypter
|
|
}
|
|
}
|
|
private void sposob3_decrypt(object sender, RoutedEventArgs e)
|
|
private void sposob3_decrypt(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
- string input = sposob3_input2.Text;
|
|
|
|
|
|
+ string input = sposob3_input2.Text, output = "";
|
|
int count = input.Count(c => c == '%');
|
|
int count = input.Count(c => c == '%');
|
|
- string output = "";
|
|
|
|
|
|
+
|
|
while (input.IndexOf($"%{count}^?") != -1)
|
|
while (input.IndexOf($"%{count}^?") != -1)
|
|
{
|
|
{
|
|
byte temp = Convert.ToByte(Convert.ToInt32(input.Substring(0, input.IndexOf($"%{count}^?"))) - count);
|
|
byte temp = Convert.ToByte(Convert.ToInt32(input.Substring(0, input.IndexOf($"%{count}^?"))) - count);
|