added project files
This commit is contained in:
parent
c0709253da
commit
cf741b2333
19
KRY-0x00-netcore.csproj
Normal file
19
KRY-0x00-netcore.csproj
Normal file
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<RootNamespace>KRY_0x00_netcore</RootNamespace>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<StartupObject>KRY_0x00_netcore.startup</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MMLib.Extensions" Version="1.0.10.13" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
25
KRY-0x00-netcore.sln
Normal file
25
KRY-0x00-netcore.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29827.131
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KRY-0x00-netcore", "KRY-0x00-netcore.csproj", "{FDB6A3B3-AAAF-4024-A861-B28A35EED7A8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FDB6A3B3-AAAF-4024-A861-B28A35EED7A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FDB6A3B3-AAAF-4024-A861-B28A35EED7A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FDB6A3B3-AAAF-4024-A861-B28A35EED7A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FDB6A3B3-AAAF-4024-A861-B28A35EED7A8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F7C27FFB-1300-4F47-A4A1-1E3B7EAF6DE3}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
179
do_a_crypto.cs
Normal file
179
do_a_crypto.cs
Normal file
@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace KRY_0x00_netcore
|
||||
{
|
||||
class do_a_crypto
|
||||
{
|
||||
private string usr_input_string;
|
||||
private string[] usr_input;
|
||||
private int alpha_usr_kee_a;
|
||||
private int beta_linear_shift;
|
||||
private int alphabet_length;
|
||||
|
||||
public int GCD(int a, int b)
|
||||
{
|
||||
while (a != 0 && b != 0)
|
||||
{
|
||||
if (a > b)
|
||||
a %= b;
|
||||
else
|
||||
b %= a;
|
||||
}
|
||||
|
||||
if (a == 0)
|
||||
return b;
|
||||
else
|
||||
return a;
|
||||
}
|
||||
protected string format_crypto_text(string crypto)
|
||||
{
|
||||
string crypto_formatted = "";
|
||||
int offset = 0;
|
||||
int todo = crypto.Length;
|
||||
|
||||
while (todo != 0)
|
||||
{
|
||||
if (offset + 5 >= crypto.Length)
|
||||
{
|
||||
for (int i = offset; i < crypto.Length; i++)
|
||||
{
|
||||
crypto_formatted += crypto.Substring(offset, 1);
|
||||
todo--;
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
else if (offset + 5 < crypto.Length)
|
||||
{
|
||||
crypto_formatted += crypto.Substring(offset, 5);
|
||||
todo -= 5;
|
||||
offset += 5;
|
||||
crypto_formatted += " ";
|
||||
}
|
||||
}
|
||||
return crypto_formatted;
|
||||
}
|
||||
|
||||
|
||||
public string encrypt(string user_input, char[] alphabet, int kee_a, int kee_b)
|
||||
{
|
||||
alphabet_length = alphabet.Length;
|
||||
|
||||
alpha_usr_kee_a = kee_a;
|
||||
beta_linear_shift = kee_b;
|
||||
string crypto = "";
|
||||
usr_input_string = user_input;
|
||||
string[] usr_input = new string[usr_input_string.Length];
|
||||
bool doing_evil_stuff = true;
|
||||
|
||||
if (GCD(alpha_usr_kee_a, alphabet_length) != 1)
|
||||
{
|
||||
MessageBox.Show("please pick another kee a, this one won't work", "do me a favour...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return null;
|
||||
}
|
||||
|
||||
Console.WriteLine("string[] usrinput ");
|
||||
for (int i = 0; i < usr_input_string.Length; i++)
|
||||
{
|
||||
usr_input[i] = usr_input_string.Substring(i, 1);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < usr_input.Length; i++)
|
||||
{
|
||||
int q = 0;
|
||||
for (int m = 0; m < alphabet.Length; m++)
|
||||
{
|
||||
if (usr_input[i] == Convert.ToString(alphabet[m]))
|
||||
{
|
||||
q = m;
|
||||
}
|
||||
}
|
||||
int OxO = ((alpha_usr_kee_a * q) + beta_linear_shift) % alphabet_length;
|
||||
Console.Write(OxO);
|
||||
crypto += $"{alphabet[OxO]}";
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
crypto = format_crypto_text(crypto);
|
||||
doing_evil_stuff = false; // :(
|
||||
return crypto;
|
||||
}
|
||||
|
||||
public string decrypt(string user_input, char[] alphabet, int kee_a, int kee_b)
|
||||
{
|
||||
alphabet_length = alphabet.Length;
|
||||
|
||||
alpha_usr_kee_a = kee_a;
|
||||
beta_linear_shift = kee_b;
|
||||
string plaintext = "";
|
||||
user_input = user_input.Replace(" ", string.Empty);
|
||||
string crypto = user_input;
|
||||
string[] usr_input = new string[crypto.Length];
|
||||
int inverse = mmi(alpha_usr_kee_a, alphabet_length);
|
||||
double dOxO;
|
||||
int OxO;
|
||||
|
||||
|
||||
if (inverse == 0)
|
||||
{
|
||||
MessageBox.Show("pick another kee a, this one sucks", "do me a favour or get BS...");
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* do evil stuff */
|
||||
Console.WriteLine($"crypted data to decrypt: {crypto}");
|
||||
|
||||
for (int i = 0; i < crypto.Length; i++)
|
||||
{
|
||||
usr_input[i] = crypto.Substring(i, 1);
|
||||
}
|
||||
|
||||
|
||||
int q;
|
||||
|
||||
for (int i = 0; i < usr_input.Length; i++)
|
||||
{
|
||||
for (int m = 0; m < alphabet.Length; m++)
|
||||
{
|
||||
if (usr_input[i] == Convert.ToString(alphabet[m]))
|
||||
{
|
||||
q = m;
|
||||
Console.WriteLine($"q: {q}, beta shift: {beta_linear_shift}, inverse: {inverse}, alphabet length: {alphabet_length}");
|
||||
|
||||
dOxO = ((q - beta_linear_shift) * inverse) % alphabet_length;
|
||||
if (dOxO < 0)
|
||||
{
|
||||
dOxO = alphabet_length + dOxO;
|
||||
}
|
||||
OxO = Convert.ToInt32(dOxO);
|
||||
plaintext += $"{alphabet[OxO]}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
plaintext = format_crypto_text(plaintext);
|
||||
return plaintext;
|
||||
}
|
||||
}
|
||||
|
||||
protected int mmi(int a, int alphlength)
|
||||
{
|
||||
int inverse;
|
||||
for (inverse = 0; inverse < alphlength; inverse++)
|
||||
{
|
||||
int darkmagic = (a * inverse) % alphlength;
|
||||
if (darkmagic == 1)
|
||||
{
|
||||
return inverse;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
242
main_form.Designer.cs
generated
Normal file
242
main_form.Designer.cs
generated
Normal file
@ -0,0 +1,242 @@
|
||||
namespace KRY_0x00_netcore
|
||||
{
|
||||
partial class main_form
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||
this.richTextBox2 = new System.Windows.Forms.RichTextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.textBox2 = new System.Windows.Forms.TextBox();
|
||||
this.richTextBox3 = new System.Windows.Forms.RichTextBox();
|
||||
this.richTextBox4 = new System.Windows.Forms.RichTextBox();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Location = new System.Drawing.Point(179, 142);
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(129, 20);
|
||||
this.textBox1.TabIndex = 1;
|
||||
//
|
||||
// richTextBox1
|
||||
//
|
||||
this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.richTextBox1.DetectUrls = false;
|
||||
this.richTextBox1.Location = new System.Drawing.Point(179, 23);
|
||||
this.richTextBox1.Name = "richTextBox1";
|
||||
this.richTextBox1.Size = new System.Drawing.Size(444, 113);
|
||||
this.richTextBox1.TabIndex = 0;
|
||||
this.richTextBox1.Text = "";
|
||||
//
|
||||
// richTextBox2
|
||||
//
|
||||
this.richTextBox2.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||
this.richTextBox2.DetectUrls = false;
|
||||
this.richTextBox2.Location = new System.Drawing.Point(179, 197);
|
||||
this.richTextBox2.Name = "richTextBox2";
|
||||
this.richTextBox2.ReadOnly = true;
|
||||
this.richTextBox2.Size = new System.Drawing.Size(444, 113);
|
||||
this.richTextBox2.TabIndex = 4;
|
||||
this.richTextBox2.Text = "";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(120, 23);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(49, 13);
|
||||
this.label1.TabIndex = 5;
|
||||
this.label1.Text = "plain text";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(135, 145);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(34, 13);
|
||||
this.label2.TabIndex = 6;
|
||||
this.label2.Text = "kee a";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(115, 244);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(54, 13);
|
||||
this.label3.TabIndex = 7;
|
||||
this.label3.Text = "dat crypto";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(179, 168);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 3;
|
||||
this.button1.Text = "go";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(713, 18);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||
this.button2.TabIndex = 4;
|
||||
this.button2.Text = "encrypting";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(641, 23);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(66, 13);
|
||||
this.label4.TabIndex = 10;
|
||||
this.label4.Text = "switch mode";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(236, 7);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(217, 13);
|
||||
this.label5.TabIndex = 11;
|
||||
this.label5.Text = "allowed characters: [A-Za-z0123456789 !?.,]";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(332, 145);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(34, 13);
|
||||
this.label6.TabIndex = 13;
|
||||
this.label6.Text = "kee b";
|
||||
//
|
||||
// textBox2
|
||||
//
|
||||
this.textBox2.Location = new System.Drawing.Point(367, 142);
|
||||
this.textBox2.Name = "textBox2";
|
||||
this.textBox2.Size = new System.Drawing.Size(129, 20);
|
||||
this.textBox2.TabIndex = 2;
|
||||
this.textBox2.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox2_KeyUp);
|
||||
//
|
||||
// richTextBox3
|
||||
//
|
||||
this.richTextBox3.Enabled = false;
|
||||
this.richTextBox3.Location = new System.Drawing.Point(179, 329);
|
||||
this.richTextBox3.Name = "richTextBox3";
|
||||
this.richTextBox3.Size = new System.Drawing.Size(444, 26);
|
||||
this.richTextBox3.TabIndex = 14;
|
||||
this.richTextBox3.Text = "";
|
||||
//
|
||||
// richTextBox4
|
||||
//
|
||||
this.richTextBox4.Enabled = false;
|
||||
this.richTextBox4.Location = new System.Drawing.Point(179, 361);
|
||||
this.richTextBox4.Name = "richTextBox4";
|
||||
this.richTextBox4.Size = new System.Drawing.Size(444, 26);
|
||||
this.richTextBox4.TabIndex = 15;
|
||||
this.richTextBox4.Text = "";
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(120, 332);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(48, 13);
|
||||
this.label7.TabIndex = 16;
|
||||
this.label7.Text = "alphabet";
|
||||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.AutoSize = true;
|
||||
this.label8.Location = new System.Drawing.Point(75, 364);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(98, 13);
|
||||
this.label8.TabIndex = 17;
|
||||
this.label8.Text = "encrypted alphabet";
|
||||
//
|
||||
// main_form
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.label8);
|
||||
this.Controls.Add(this.label7);
|
||||
this.Controls.Add(this.richTextBox4);
|
||||
this.Controls.Add(this.richTextBox3);
|
||||
this.Controls.Add(this.label6);
|
||||
this.Controls.Add(this.textBox2);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.richTextBox2);
|
||||
this.Controls.Add(this.richTextBox1);
|
||||
this.Controls.Add(this.textBox1);
|
||||
this.Name = "main_form";
|
||||
this.Text = "kry-0x00-netcore";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.RichTextBox richTextBox1;
|
||||
private System.Windows.Forms.RichTextBox richTextBox2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.TextBox textBox2;
|
||||
private System.Windows.Forms.RichTextBox richTextBox3;
|
||||
private System.Windows.Forms.RichTextBox richTextBox4;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.Label label8;
|
||||
}
|
||||
}
|
272
main_form.cs
Normal file
272
main_form.cs
Normal file
@ -0,0 +1,272 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace KRY_0x00_netcore
|
||||
{
|
||||
public partial class main_form : Form
|
||||
{
|
||||
public main_form()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected bool encr = true;
|
||||
protected int enc = 1;
|
||||
public char[] alphabet = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
|
||||
public char[] allowed_characters = { ' ', '.', ',', '!', '?', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '\n' };
|
||||
public char[] getalph()
|
||||
{
|
||||
return alphabet;
|
||||
}
|
||||
|
||||
string user_input;
|
||||
public string User_input { get => user_input; set => user_input = richTextBox1.Text; }
|
||||
|
||||
|
||||
|
||||
public static string transliterate(string textik)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textik))
|
||||
return textik;
|
||||
|
||||
return MMLib.Extensions.StringExtensions.RemoveDiacritics(textik);
|
||||
}
|
||||
|
||||
public string find_bad_boiz(string group_of_mixed_boiz)
|
||||
{
|
||||
/*
|
||||
* allowed chars: "A-Z0123456789 !?.,"
|
||||
*/
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.ToUpper();
|
||||
for (int i = 0; i < group_of_mixed_boiz.Length; i++)
|
||||
{
|
||||
bool report_error = true;
|
||||
|
||||
string a = group_of_mixed_boiz.Substring(i, 1);
|
||||
for (int m = 0; m < alphabet.Length; m++)
|
||||
{
|
||||
if (a == Convert.ToString(alphabet[m]))
|
||||
{
|
||||
report_error = false;
|
||||
}
|
||||
}
|
||||
for (int n = 0; n < allowed_characters.Length; n++)
|
||||
{
|
||||
if (a == Convert.ToString(allowed_characters[n]))
|
||||
{
|
||||
report_error = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (report_error)
|
||||
{
|
||||
MessageBox.Show($"error: \"{a}\" is not a valid character", "u screwed");
|
||||
}
|
||||
}
|
||||
|
||||
if (group_of_mixed_boiz != transliterate(group_of_mixed_boiz))
|
||||
{
|
||||
_ = MessageBox.Show("diacritics will not be preserved!", "just so you know...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
group_of_mixed_boiz = transliterate(group_of_mixed_boiz);
|
||||
|
||||
string corrected_group = "";
|
||||
for (int i = 0; i < group_of_mixed_boiz.Length; i++)
|
||||
{
|
||||
string boi = group_of_mixed_boiz.Substring(i, 1);
|
||||
|
||||
/* classic misdirection */
|
||||
if (boi == " ")
|
||||
{ boi = "VYKRICNIKBRO"; }
|
||||
else if (boi == "!")
|
||||
{ boi = "MEDZERABRO"; }
|
||||
else if (boi == "?")
|
||||
{ boi = "BODKABRO"; }
|
||||
else if (boi == ".")
|
||||
{ boi = "OTAZNIKBRO"; }
|
||||
else if (boi == ",")
|
||||
{ boi = "SLONBRO"; }
|
||||
else if (boi == "0")
|
||||
{ boi = "NULABRO"; }
|
||||
else if (boi == "1")
|
||||
{ boi = "JEDNABRO"; }
|
||||
else if (boi == "2")
|
||||
{ boi = "STODESATBRO"; }
|
||||
else if (boi == "3")
|
||||
{ boi = "MILIONBRO"; }
|
||||
else if (boi == "4")
|
||||
{ boi = "PADESATBRO"; }
|
||||
else if (boi == "5")
|
||||
{ boi = "DEVATBRO"; }
|
||||
else if (boi == "6")
|
||||
{ boi = "HNEDBRO"; }
|
||||
else if (boi == "7")
|
||||
{ boi = "CHCEMSPATBRO"; }
|
||||
else if (boi == "8")
|
||||
{ boi = "ORELBRO"; }
|
||||
else if (boi == "9")
|
||||
{ boi = "TRISTOBRO"; }
|
||||
else if (boi == "\n")
|
||||
{ boi = "NEWLINEBRO"; }
|
||||
//else
|
||||
//{
|
||||
/* boi good*/
|
||||
//}
|
||||
corrected_group = corrected_group + $"{boi}";
|
||||
}
|
||||
return corrected_group;
|
||||
}
|
||||
|
||||
public string reverse_boiz(string group_of_mixed_boiz)
|
||||
{
|
||||
string corrected_group = "";
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.ToUpper();
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace(" ", string.Empty);
|
||||
|
||||
for (int i = 0; i < group_of_mixed_boiz.Length; i++)
|
||||
{
|
||||
Match matchallowed = Regex.Match(group_of_mixed_boiz,
|
||||
@"(VYKRICNIKBRO)|(MEDZERABRO)|(BODKABRO)|(OTAZNIKBRO)|(SLONBRO)|
|
||||
(NULABRO)|(JEDNABRO)|(STODESATBRO)|(MILIONBRO)|(PADESATBRO)|
|
||||
(DEVATBRO)|(HNEDBRO)|(CHCEMSPATBRO)|(ORELBRO)|(TRISTOBRO)|
|
||||
(NEWLINEBRO)", RegexOptions.IgnoreCase);
|
||||
|
||||
if (matchallowed.Success)
|
||||
{
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("VYKRICNIKBRO", " ");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("MEDZERABRO", "!");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("BODKABRO", "?");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("OTAZNIKBRO", ".");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("SLONBRO", ",");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("NULABRO", "0");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("JADNABRO", "1");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("STODESATBRO", "2");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("MILIONBRO", "3");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("PADESATBRO", "4");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("DEVATBRO", "5");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("HNEDBRO", "6");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("CHCEMSPATBRO", "7");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("ORELBRO", "8");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("TRISTOBRO", "9");
|
||||
group_of_mixed_boiz = group_of_mixed_boiz.Replace("NEWLINEBRO", "\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (corrected_group == "")
|
||||
{
|
||||
return group_of_mixed_boiz;
|
||||
}
|
||||
else return corrected_group;
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
/*
|
||||
* mode shifting
|
||||
*/
|
||||
|
||||
enc *= (-1);
|
||||
if (enc < 0)
|
||||
{
|
||||
encr = false;
|
||||
button2.Text = "decrypting";
|
||||
}
|
||||
else if (enc > 0)
|
||||
{
|
||||
encr = true;
|
||||
button2.Text = "encrypting";
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
/*
|
||||
* go button
|
||||
* [*] do evil stuff
|
||||
*/
|
||||
bool not_done = true;
|
||||
|
||||
while (not_done)
|
||||
{
|
||||
// check for empty text - done
|
||||
string usr_input = richTextBox1.Text;
|
||||
User_input = usr_input;
|
||||
if (User_input == "")
|
||||
{
|
||||
MessageBox.Show("at least gimme some text", "well...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
not_done = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
char[] alph = getalph();
|
||||
int kee_a;
|
||||
int kee_b;
|
||||
try
|
||||
{
|
||||
kee_a = Convert.ToInt32(textBox1.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
_ = MessageBox.Show("attempted to use forbidden value as kee a\nhint - use a number", "repent or die", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
break;
|
||||
}
|
||||
try
|
||||
{
|
||||
kee_b = Convert.ToInt32(textBox2.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
_ = MessageBox.Show("attempted to use forbidden value as kee b\nhint - use a number", "repent or die", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
break;
|
||||
}
|
||||
|
||||
do_a_crypto do_a_Crypto = new do_a_crypto();
|
||||
richTextBox3.Text = "";
|
||||
for (int i = 0; i < alphabet.Length; i++)
|
||||
{
|
||||
richTextBox3.Text += alphabet[i];
|
||||
}
|
||||
richTextBox4.Text = do_a_Crypto.encrypt(richTextBox3.Text, alph, kee_a, kee_b);
|
||||
|
||||
if (encr)
|
||||
{
|
||||
Console.WriteLine("user input unparsed: " + User_input);
|
||||
string parsed_input = find_bad_boiz(User_input);
|
||||
Console.WriteLine("user input parsed: " + parsed_input);
|
||||
|
||||
richTextBox2.Text = do_a_Crypto.encrypt(parsed_input, alph, kee_a, kee_b);
|
||||
Console.WriteLine(richTextBox2.Text);
|
||||
break;
|
||||
}
|
||||
else if (!encr)
|
||||
{
|
||||
richTextBox2.Text = reverse_boiz(do_a_Crypto.decrypt(user_input, alph, kee_a, kee_b));
|
||||
Console.WriteLine(richTextBox2.Text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox2_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
button1.PerformClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
35
startup.cs
Normal file
35
startup.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace KRY_0x00_netcore
|
||||
{
|
||||
class startup
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
Console.WriteLine($"" +
|
||||
"************************************************************\n" +
|
||||
"# # ###### # # ### ### ### \n" +
|
||||
"# # # # # # # # # # # # # # \n" +
|
||||
"# # # # # # # # # # # # # # \n" +
|
||||
"### ###### # ##### # # ## # # # # \n" +
|
||||
"# # # # # # # ## # # # # \n" +
|
||||
"# # # # # # # # # # # # # \n" +
|
||||
"# # # # # ### # # ### ### \n" +
|
||||
".netcore edition\n" +
|
||||
"************************************************************\n");
|
||||
Console.WriteLine("Welcome to KRY-0x00 .netcore edition");
|
||||
Console.WriteLine("This app was created for the purpose of demonstration of affine cipher");
|
||||
Console.WriteLine("Press any key to continue...");
|
||||
Console.Read();
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new main_form());
|
||||
Console.Read();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user