|
@@ -20,6 +20,7 @@ namespace Encrypter
|
|
|
/// </summary>
|
|
|
public partial class MainWindow : Window
|
|
|
{
|
|
|
+ Encoding ascii = Encoding.ASCII;
|
|
|
public MainWindow()
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -27,12 +28,27 @@ namespace Encrypter
|
|
|
|
|
|
private void sposob3_encrypt(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- Encoding ascii = Encoding.ASCII;
|
|
|
string input = sposob3_input.Text, output = "";
|
|
|
Byte[] encodedBytes = ascii.GetBytes(input);
|
|
|
foreach (Byte b in encodedBytes)
|
|
|
- output += $"{b + input.Length}%^?";
|
|
|
+ output += $"{b + input.Length}%{input.Length}^?";
|
|
|
sposob3_output.Text = output;
|
|
|
}
|
|
|
+ private void sposob3_decrypt(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ string input = sposob3_input2.Text;
|
|
|
+ int count = input.Count(c => c == '%');
|
|
|
+ string output = "";
|
|
|
+ while(input.IndexOf($"%{count}^?") != -1)
|
|
|
+ {
|
|
|
+ byte temp = Convert.ToByte(Convert.ToInt32(input.Substring(0, input.IndexOf($"%{count}^?"))) - count);
|
|
|
+ output += Convert.ToChar(temp);
|
|
|
+ MessageBox.Show("output = " + output);
|
|
|
+ input = input.Remove(0, output.Length+4);
|
|
|
+ MessageBox.Show("input = " + input);
|
|
|
+ }
|
|
|
+ sposob3_output2.Text = output;
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|