Browse Source

Encryption Example Added

wook 4 years ago
parent
commit
ddbd02b51a

+ 6
- 0
Encryption.Example/App.config View File

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="utf-8" ?>
2
+<configuration>
3
+    <startup> 
4
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5
+    </startup>
6
+</configuration>

+ 223
- 0
Encryption.Example/Cryptography.Designer.cs View File

@@ -0,0 +1,223 @@
1
+namespace Encryption.Example
2
+{
3
+	partial class Cryptography
4
+	{
5
+		/// <summary>
6
+		/// Required designer variable.
7
+		/// </summary>
8
+		private System.ComponentModel.IContainer components = null;
9
+
10
+		/// <summary>
11
+		/// Clean up any resources being used.
12
+		/// </summary>
13
+		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
14
+		protected override void Dispose(bool disposing)
15
+		{
16
+			if (disposing && (components != null))
17
+			{
18
+				components.Dispose();
19
+			}
20
+			base.Dispose(disposing);
21
+		}
22
+
23
+		#region Windows Form Designer generated code
24
+
25
+		/// <summary>
26
+		/// Required method for Designer support - do not modify
27
+		/// the contents of this method with the code editor.
28
+		/// </summary>
29
+		private void InitializeComponent()
30
+		{
31
+			this.lblKey = new System.Windows.Forms.Label();
32
+			this.txtKey = new System.Windows.Forms.TextBox();
33
+			this.btnGenerate = new System.Windows.Forms.Button();
34
+			this.groupBox1 = new System.Windows.Forms.GroupBox();
35
+			this.lblIV = new System.Windows.Forms.Label();
36
+			this.txtIV = new System.Windows.Forms.TextBox();
37
+			this.groupBox2 = new System.Windows.Forms.GroupBox();
38
+			this.txtFlat = new System.Windows.Forms.TextBox();
39
+			this.lblTextDecryptedResult = new System.Windows.Forms.Label();
40
+			this.btnEncrypt = new System.Windows.Forms.Button();
41
+			this.lblTextDecrypted = new System.Windows.Forms.Label();
42
+			this.lblTextEncryptedResult = new System.Windows.Forms.Label();
43
+			this.lblTextEncrypted = new System.Windows.Forms.Label();
44
+			this.lblTextFlat = new System.Windows.Forms.Label();
45
+			this.groupBox1.SuspendLayout();
46
+			this.groupBox2.SuspendLayout();
47
+			this.SuspendLayout();
48
+			// 
49
+			// lblKey
50
+			// 
51
+			this.lblKey.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
52
+			this.lblKey.Location = new System.Drawing.Point(6, 16);
53
+			this.lblKey.Name = "lblKey";
54
+			this.lblKey.Size = new System.Drawing.Size(50, 23);
55
+			this.lblKey.TabIndex = 0;
56
+			this.lblKey.Text = "Key";
57
+			// 
58
+			// txtKey
59
+			// 
60
+			this.txtKey.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
61
+			this.txtKey.Location = new System.Drawing.Point(62, 19);
62
+			this.txtKey.Name = "txtKey";
63
+			this.txtKey.Size = new System.Drawing.Size(398, 23);
64
+			this.txtKey.TabIndex = 1;
65
+			// 
66
+			// btnGenerate
67
+			// 
68
+			this.btnGenerate.Location = new System.Drawing.Point(336, 71);
69
+			this.btnGenerate.Name = "btnGenerate";
70
+			this.btnGenerate.Size = new System.Drawing.Size(124, 23);
71
+			this.btnGenerate.TabIndex = 3;
72
+			this.btnGenerate.Text = "Generate Key and IV";
73
+			this.btnGenerate.UseVisualStyleBackColor = true;
74
+			this.btnGenerate.Click += new System.EventHandler(this.btnGenerate_Click);
75
+			// 
76
+			// groupBox1
77
+			// 
78
+			this.groupBox1.Controls.Add(this.lblIV);
79
+			this.groupBox1.Controls.Add(this.lblKey);
80
+			this.groupBox1.Controls.Add(this.btnGenerate);
81
+			this.groupBox1.Controls.Add(this.txtIV);
82
+			this.groupBox1.Controls.Add(this.txtKey);
83
+			this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
84
+			this.groupBox1.Location = new System.Drawing.Point(0, 0);
85
+			this.groupBox1.Name = "groupBox1";
86
+			this.groupBox1.Size = new System.Drawing.Size(472, 97);
87
+			this.groupBox1.TabIndex = 3;
88
+			this.groupBox1.TabStop = false;
89
+			this.groupBox1.Text = "Key and IV";
90
+			// 
91
+			// lblIV
92
+			// 
93
+			this.lblIV.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
94
+			this.lblIV.Location = new System.Drawing.Point(6, 42);
95
+			this.lblIV.Name = "lblIV";
96
+			this.lblIV.Size = new System.Drawing.Size(50, 23);
97
+			this.lblIV.TabIndex = 0;
98
+			this.lblIV.Text = "IV";
99
+			// 
100
+			// txtIV
101
+			// 
102
+			this.txtIV.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
103
+			this.txtIV.Location = new System.Drawing.Point(62, 45);
104
+			this.txtIV.Name = "txtIV";
105
+			this.txtIV.Size = new System.Drawing.Size(398, 23);
106
+			this.txtIV.TabIndex = 2;
107
+			// 
108
+			// groupBox2
109
+			// 
110
+			this.groupBox2.Controls.Add(this.txtFlat);
111
+			this.groupBox2.Controls.Add(this.lblTextDecryptedResult);
112
+			this.groupBox2.Controls.Add(this.btnEncrypt);
113
+			this.groupBox2.Controls.Add(this.lblTextDecrypted);
114
+			this.groupBox2.Controls.Add(this.lblTextEncryptedResult);
115
+			this.groupBox2.Controls.Add(this.lblTextEncrypted);
116
+			this.groupBox2.Controls.Add(this.lblTextFlat);
117
+			this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
118
+			this.groupBox2.Location = new System.Drawing.Point(0, 97);
119
+			this.groupBox2.Name = "groupBox2";
120
+			this.groupBox2.Size = new System.Drawing.Size(472, 123);
121
+			this.groupBox2.TabIndex = 4;
122
+			this.groupBox2.TabStop = false;
123
+			this.groupBox2.Text = "Encryption and Decryption";
124
+			// 
125
+			// txtFlat
126
+			// 
127
+			this.txtFlat.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
128
+			this.txtFlat.Location = new System.Drawing.Point(106, 19);
129
+			this.txtFlat.Name = "txtFlat";
130
+			this.txtFlat.Size = new System.Drawing.Size(354, 23);
131
+			this.txtFlat.TabIndex = 4;
132
+			this.txtFlat.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtFlat_KeyDown);
133
+			// 
134
+			// lblTextDecryptedResult
135
+			// 
136
+			this.lblTextDecryptedResult.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
137
+			this.lblTextDecryptedResult.Location = new System.Drawing.Point(106, 70);
138
+			this.lblTextDecryptedResult.Name = "lblTextDecryptedResult";
139
+			this.lblTextDecryptedResult.Size = new System.Drawing.Size(354, 23);
140
+			this.lblTextDecryptedResult.TabIndex = 0;
141
+			// 
142
+			// btnEncrypt
143
+			// 
144
+			this.btnEncrypt.Location = new System.Drawing.Point(336, 96);
145
+			this.btnEncrypt.Name = "btnEncrypt";
146
+			this.btnEncrypt.Size = new System.Drawing.Size(124, 23);
147
+			this.btnEncrypt.TabIndex = 5;
148
+			this.btnEncrypt.Text = "Encrypt";
149
+			this.btnEncrypt.UseVisualStyleBackColor = true;
150
+			this.btnEncrypt.Click += new System.EventHandler(this.btnEncrypt_Click);
151
+			// 
152
+			// lblTextDecrypted
153
+			// 
154
+			this.lblTextDecrypted.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
155
+			this.lblTextDecrypted.Location = new System.Drawing.Point(6, 70);
156
+			this.lblTextDecrypted.Name = "lblTextDecrypted";
157
+			this.lblTextDecrypted.Size = new System.Drawing.Size(94, 23);
158
+			this.lblTextDecrypted.TabIndex = 0;
159
+			this.lblTextDecrypted.Text = "Decrypted";
160
+			// 
161
+			// lblTextEncryptedResult
162
+			// 
163
+			this.lblTextEncryptedResult.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
164
+			this.lblTextEncryptedResult.Location = new System.Drawing.Point(106, 45);
165
+			this.lblTextEncryptedResult.Name = "lblTextEncryptedResult";
166
+			this.lblTextEncryptedResult.Size = new System.Drawing.Size(354, 23);
167
+			this.lblTextEncryptedResult.TabIndex = 0;
168
+			// 
169
+			// lblTextEncrypted
170
+			// 
171
+			this.lblTextEncrypted.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
172
+			this.lblTextEncrypted.Location = new System.Drawing.Point(6, 45);
173
+			this.lblTextEncrypted.Name = "lblTextEncrypted";
174
+			this.lblTextEncrypted.Size = new System.Drawing.Size(94, 23);
175
+			this.lblTextEncrypted.TabIndex = 0;
176
+			this.lblTextEncrypted.Text = "Encrypted";
177
+			// 
178
+			// lblTextFlat
179
+			// 
180
+			this.lblTextFlat.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
181
+			this.lblTextFlat.Location = new System.Drawing.Point(6, 20);
182
+			this.lblTextFlat.Name = "lblTextFlat";
183
+			this.lblTextFlat.Size = new System.Drawing.Size(94, 23);
184
+			this.lblTextFlat.TabIndex = 0;
185
+			this.lblTextFlat.Text = "Flat Text";
186
+			// 
187
+			// Cryptography
188
+			// 
189
+			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
190
+			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
191
+			this.ClientSize = new System.Drawing.Size(472, 220);
192
+			this.Controls.Add(this.groupBox2);
193
+			this.Controls.Add(this.groupBox1);
194
+			this.Name = "Cryptography";
195
+			this.Text = "Crypto";
196
+			this.Load += new System.EventHandler(this.Cryptography_Load);
197
+			this.groupBox1.ResumeLayout(false);
198
+			this.groupBox1.PerformLayout();
199
+			this.groupBox2.ResumeLayout(false);
200
+			this.groupBox2.PerformLayout();
201
+			this.ResumeLayout(false);
202
+
203
+		}
204
+
205
+		#endregion
206
+
207
+		private System.Windows.Forms.Label lblKey;
208
+		private System.Windows.Forms.TextBox txtKey;
209
+		private System.Windows.Forms.Button btnGenerate;
210
+		private System.Windows.Forms.GroupBox groupBox1;
211
+		private System.Windows.Forms.Label lblIV;
212
+		private System.Windows.Forms.TextBox txtIV;
213
+		private System.Windows.Forms.GroupBox groupBox2;
214
+		private System.Windows.Forms.TextBox txtFlat;
215
+		private System.Windows.Forms.Label lblTextDecryptedResult;
216
+		private System.Windows.Forms.Label lblTextDecrypted;
217
+		private System.Windows.Forms.Label lblTextEncryptedResult;
218
+		private System.Windows.Forms.Label lblTextEncrypted;
219
+		private System.Windows.Forms.Label lblTextFlat;
220
+		private System.Windows.Forms.Button btnEncrypt;
221
+	}
222
+}
223
+

+ 80
- 0
Encryption.Example/Cryptography.cs View File

@@ -0,0 +1,80 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+using Encryption;
11
+
12
+namespace Encryption.Example
13
+{
14
+	public partial class Cryptography : Form
15
+	{
16
+		List<byte[]> KEYS = new Crypto().GenerateKeyAndIV();
17
+		public Cryptography()
18
+		{
19
+			InitializeComponent();
20
+		}
21
+
22
+		private void Cryptography_Load(object sender, EventArgs e)
23
+		{
24
+			this.GenerateKeyAndIV();
25
+		}
26
+
27
+		private void GenerateKeyAndIV()
28
+		{
29
+			string[] str = new string[] { string.Empty, string.Empty };
30
+
31
+			for (int i = 0; i < 2; i++)
32
+			{
33
+				foreach (byte b in this.KEYS[i])
34
+				{
35
+					str[i] += b.ToString() + ", ";
36
+				}
37
+			}
38
+			this.txtKey.Text = str[0].Substring(0, str[0].Length - 2);
39
+			this.txtIV.Text = str[1].Substring(0, str[1].Length - 2);
40
+		}
41
+
42
+		private void EncryptAndDecrypt()
43
+		{
44
+			Crypto crypto = new Crypto();
45
+
46
+			if (this.txtFlat.Text.Length > 0)
47
+			{
48
+				this.lblTextEncryptedResult.Text = crypto.Encrypt(this.txtFlat.Text, this.KEYS[0], this.KEYS[1]);
49
+				this.lblTextDecryptedResult.Text = crypto.Decrypt(this.lblTextEncryptedResult.Text, this.KEYS.ElementAt(0), this.KEYS.ElementAt(1));
50
+			}
51
+			else
52
+			{
53
+				MessageBox.Show("Enter any word in the flat text box");
54
+				this.txtFlat.Focus();
55
+			}
56
+		}
57
+
58
+		private void btnGenerate_Click(object sender, EventArgs e)
59
+		{
60
+			this.GenerateKeyAndIV();
61
+			this.txtFlat.Focus();
62
+		}
63
+
64
+		private void btnEncrypt_Click(object sender, EventArgs e)
65
+		{
66
+			this.EncryptAndDecrypt();
67
+		}
68
+
69
+		private void txtFlat_KeyDown(object sender, KeyEventArgs e)
70
+		{
71
+			switch (e.KeyCode)
72
+			{
73
+				case Keys.Enter:
74
+					this.EncryptAndDecrypt();
75
+					break;
76
+			}
77
+		}
78
+
79
+	}
80
+}

+ 120
- 0
Encryption.Example/Cryptography.resx View File

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 88
- 0
Encryption.Example/Encryption.Example.csproj View File

@@ -0,0 +1,88 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
+  <PropertyGroup>
5
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
+    <ProjectGuid>{78410A07-457D-4CDD-B5BA-C2FA8C663689}</ProjectGuid>
8
+    <OutputType>WinExe</OutputType>
9
+    <RootNamespace>Encryption.Example</RootNamespace>
10
+    <AssemblyName>Encryption.Example</AssemblyName>
11
+    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12
+    <FileAlignment>512</FileAlignment>
13
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14
+  </PropertyGroup>
15
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16
+    <PlatformTarget>AnyCPU</PlatformTarget>
17
+    <DebugSymbols>true</DebugSymbols>
18
+    <DebugType>full</DebugType>
19
+    <Optimize>false</Optimize>
20
+    <OutputPath>bin\Debug\</OutputPath>
21
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
22
+    <ErrorReport>prompt</ErrorReport>
23
+    <WarningLevel>4</WarningLevel>
24
+  </PropertyGroup>
25
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26
+    <PlatformTarget>AnyCPU</PlatformTarget>
27
+    <DebugType>pdbonly</DebugType>
28
+    <Optimize>true</Optimize>
29
+    <OutputPath>bin\Release\</OutputPath>
30
+    <DefineConstants>TRACE</DefineConstants>
31
+    <ErrorReport>prompt</ErrorReport>
32
+    <WarningLevel>4</WarningLevel>
33
+  </PropertyGroup>
34
+  <ItemGroup>
35
+    <Reference Include="System" />
36
+    <Reference Include="System.Core" />
37
+    <Reference Include="System.Xml.Linq" />
38
+    <Reference Include="System.Data.DataSetExtensions" />
39
+    <Reference Include="Microsoft.CSharp" />
40
+    <Reference Include="System.Data" />
41
+    <Reference Include="System.Deployment" />
42
+    <Reference Include="System.Drawing" />
43
+    <Reference Include="System.Net.Http" />
44
+    <Reference Include="System.Windows.Forms" />
45
+    <Reference Include="System.Xml" />
46
+  </ItemGroup>
47
+  <ItemGroup>
48
+    <Compile Include="Cryptography.cs">
49
+      <SubType>Form</SubType>
50
+    </Compile>
51
+    <Compile Include="Cryptography.Designer.cs">
52
+      <DependentUpon>Cryptography.cs</DependentUpon>
53
+    </Compile>
54
+    <Compile Include="Program.cs" />
55
+    <Compile Include="Properties\AssemblyInfo.cs" />
56
+    <EmbeddedResource Include="Cryptography.resx">
57
+      <DependentUpon>Cryptography.cs</DependentUpon>
58
+    </EmbeddedResource>
59
+    <EmbeddedResource Include="Properties\Resources.resx">
60
+      <Generator>ResXFileCodeGenerator</Generator>
61
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
62
+      <SubType>Designer</SubType>
63
+    </EmbeddedResource>
64
+    <Compile Include="Properties\Resources.Designer.cs">
65
+      <AutoGen>True</AutoGen>
66
+      <DependentUpon>Resources.resx</DependentUpon>
67
+    </Compile>
68
+    <None Include="Properties\Settings.settings">
69
+      <Generator>SettingsSingleFileGenerator</Generator>
70
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
71
+    </None>
72
+    <Compile Include="Properties\Settings.Designer.cs">
73
+      <AutoGen>True</AutoGen>
74
+      <DependentUpon>Settings.settings</DependentUpon>
75
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
76
+    </Compile>
77
+  </ItemGroup>
78
+  <ItemGroup>
79
+    <None Include="App.config" />
80
+  </ItemGroup>
81
+  <ItemGroup>
82
+    <ProjectReference Include="..\Encryption\Encryption.csproj">
83
+      <Project>{ed031a70-570f-4599-ac04-0453a997a6a4}</Project>
84
+      <Name>Encryption</Name>
85
+    </ProjectReference>
86
+  </ItemGroup>
87
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
88
+</Project>

+ 22
- 0
Encryption.Example/Program.cs View File

@@ -0,0 +1,22 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using System.Windows.Forms;
6
+
7
+namespace Encryption.Example
8
+{
9
+	static class Program
10
+	{
11
+		/// <summary>
12
+		/// The main entry point for the application.
13
+		/// </summary>
14
+		[STAThread]
15
+		static void Main()
16
+		{
17
+			Application.EnableVisualStyles();
18
+			Application.SetCompatibleTextRenderingDefault(false);
19
+			Application.Run(new Cryptography());
20
+		}
21
+	}
22
+}

+ 36
- 0
Encryption.Example/Properties/AssemblyInfo.cs View File

@@ -0,0 +1,36 @@
1
+using System.Reflection;
2
+using System.Runtime.CompilerServices;
3
+using System.Runtime.InteropServices;
4
+
5
+// General Information about an assembly is controlled through the following
6
+// set of attributes. Change these attribute values to modify the information
7
+// associated with an assembly.
8
+[assembly: AssemblyTitle("Encryption.Example")]
9
+[assembly: AssemblyDescription("")]
10
+[assembly: AssemblyConfiguration("")]
11
+[assembly: AssemblyCompany("")]
12
+[assembly: AssemblyProduct("Encryption.Example")]
13
+[assembly: AssemblyCopyright("Copyright ©  2017")]
14
+[assembly: AssemblyTrademark("")]
15
+[assembly: AssemblyCulture("")]
16
+
17
+// Setting ComVisible to false makes the types in this assembly not visible
18
+// to COM components.  If you need to access a type in this assembly from
19
+// COM, set the ComVisible attribute to true on that type.
20
+[assembly: ComVisible(false)]
21
+
22
+// The following GUID is for the ID of the typelib if this project is exposed to COM
23
+[assembly: Guid("78410a07-457d-4cdd-b5ba-c2fa8c663689")]
24
+
25
+// Version information for an assembly consists of the following four values:
26
+//
27
+//      Major Version
28
+//      Minor Version
29
+//      Build Number
30
+//      Revision
31
+//
32
+// You can specify all the values or you can default the Build and Revision Numbers
33
+// by using the '*' as shown below:
34
+// [assembly: AssemblyVersion("1.0.*")]
35
+[assembly: AssemblyVersion("1.0.0.0")]
36
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71
- 0
Encryption.Example/Properties/Resources.Designer.cs View File

@@ -0,0 +1,71 @@
1
+//------------------------------------------------------------------------------
2
+// <auto-generated>
3
+//     This code was generated by a tool.
4
+//     Runtime Version:4.0.30319.42000
5
+//
6
+//     Changes to this file may cause incorrect behavior and will be lost if
7
+//     the code is regenerated.
8
+// </auto-generated>
9
+//------------------------------------------------------------------------------
10
+
11
+namespace Encryption.Example.Properties
12
+{
13
+
14
+
15
+	/// <summary>
16
+	///   A strongly-typed resource class, for looking up localized strings, etc.
17
+	/// </summary>
18
+	// This class was auto-generated by the StronglyTypedResourceBuilder
19
+	// class via a tool like ResGen or Visual Studio.
20
+	// To add or remove a member, edit your .ResX file then rerun ResGen
21
+	// with the /str option, or rebuild your VS project.
22
+	[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23
+	[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24
+	[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25
+	internal class Resources
26
+	{
27
+
28
+		private static global::System.Resources.ResourceManager resourceMan;
29
+
30
+		private static global::System.Globalization.CultureInfo resourceCulture;
31
+
32
+		[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33
+		internal Resources()
34
+		{
35
+		}
36
+
37
+		/// <summary>
38
+		///   Returns the cached ResourceManager instance used by this class.
39
+		/// </summary>
40
+		[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41
+		internal static global::System.Resources.ResourceManager ResourceManager
42
+		{
43
+			get
44
+			{
45
+				if ((resourceMan == null))
46
+				{
47
+					global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Encryption.Example.Properties.Resources", typeof(Resources).Assembly);
48
+					resourceMan = temp;
49
+				}
50
+				return resourceMan;
51
+			}
52
+		}
53
+
54
+		/// <summary>
55
+		///   Overrides the current thread's CurrentUICulture property for all
56
+		///   resource lookups using this strongly typed resource class.
57
+		/// </summary>
58
+		[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59
+		internal static global::System.Globalization.CultureInfo Culture
60
+		{
61
+			get
62
+			{
63
+				return resourceCulture;
64
+			}
65
+			set
66
+			{
67
+				resourceCulture = value;
68
+			}
69
+		}
70
+	}
71
+}

+ 117
- 0
Encryption.Example/Properties/Resources.resx View File

@@ -0,0 +1,117 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:element name="root" msdata:IsDataSet="true">
64
+      <xsd:complexType>
65
+        <xsd:choice maxOccurs="unbounded">
66
+          <xsd:element name="metadata">
67
+            <xsd:complexType>
68
+              <xsd:sequence>
69
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
70
+              </xsd:sequence>
71
+              <xsd:attribute name="name" type="xsd:string" />
72
+              <xsd:attribute name="type" type="xsd:string" />
73
+              <xsd:attribute name="mimetype" type="xsd:string" />
74
+            </xsd:complexType>
75
+          </xsd:element>
76
+          <xsd:element name="assembly">
77
+            <xsd:complexType>
78
+              <xsd:attribute name="alias" type="xsd:string" />
79
+              <xsd:attribute name="name" type="xsd:string" />
80
+            </xsd:complexType>
81
+          </xsd:element>
82
+          <xsd:element name="data">
83
+            <xsd:complexType>
84
+              <xsd:sequence>
85
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
86
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
87
+              </xsd:sequence>
88
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
89
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
90
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
91
+            </xsd:complexType>
92
+          </xsd:element>
93
+          <xsd:element name="resheader">
94
+            <xsd:complexType>
95
+              <xsd:sequence>
96
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
97
+              </xsd:sequence>
98
+              <xsd:attribute name="name" type="xsd:string" use="required" />
99
+            </xsd:complexType>
100
+          </xsd:element>
101
+        </xsd:choice>
102
+      </xsd:complexType>
103
+    </xsd:element>
104
+  </xsd:schema>
105
+  <resheader name="resmimetype">
106
+    <value>text/microsoft-resx</value>
107
+  </resheader>
108
+  <resheader name="version">
109
+    <value>2.0</value>
110
+  </resheader>
111
+  <resheader name="reader">
112
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
113
+  </resheader>
114
+  <resheader name="writer">
115
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+</root>

+ 30
- 0
Encryption.Example/Properties/Settings.Designer.cs View File

@@ -0,0 +1,30 @@
1
+//------------------------------------------------------------------------------
2
+// <auto-generated>
3
+//     This code was generated by a tool.
4
+//     Runtime Version:4.0.30319.42000
5
+//
6
+//     Changes to this file may cause incorrect behavior and will be lost if
7
+//     the code is regenerated.
8
+// </auto-generated>
9
+//------------------------------------------------------------------------------
10
+
11
+namespace Encryption.Example.Properties
12
+{
13
+
14
+
15
+	[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16
+	[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17
+	internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18
+	{
19
+
20
+		private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21
+
22
+		public static Settings Default
23
+		{
24
+			get
25
+			{
26
+				return defaultInstance;
27
+			}
28
+		}
29
+	}
30
+}

+ 7
- 0
Encryption.Example/Properties/Settings.settings View File

@@ -0,0 +1,7 @@
1
+<?xml version='1.0' encoding='utf-8'?>
2
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
3
+  <Profiles>
4
+    <Profile Name="(Default)" />
5
+  </Profiles>
6
+  <Settings />
7
+</SettingsFile>

+ 6
- 0
Encryption.sln View File

@@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.26403.7
5 5
 MinimumVisualStudioVersion = 10.0.40219.1
6 6
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encryption", "Encryption\Encryption.csproj", "{ED031A70-570F-4599-AC04-0453A997A6A4}"
7 7
 EndProject
8
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encryption.Example", "Encryption.Example\Encryption.Example.csproj", "{78410A07-457D-4CDD-B5BA-C2FA8C663689}"
9
+EndProject
8 10
 Global
9 11
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 12
 		Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
15 17
 		{ED031A70-570F-4599-AC04-0453A997A6A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 18
 		{ED031A70-570F-4599-AC04-0453A997A6A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 19
 		{ED031A70-570F-4599-AC04-0453A997A6A4}.Release|Any CPU.Build.0 = Release|Any CPU
20
+		{78410A07-457D-4CDD-B5BA-C2FA8C663689}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21
+		{78410A07-457D-4CDD-B5BA-C2FA8C663689}.Debug|Any CPU.Build.0 = Debug|Any CPU
22
+		{78410A07-457D-4CDD-B5BA-C2FA8C663689}.Release|Any CPU.ActiveCfg = Release|Any CPU
23
+		{78410A07-457D-4CDD-B5BA-C2FA8C663689}.Release|Any CPU.Build.0 = Release|Any CPU
18 24
 	EndGlobalSection
19 25
 	GlobalSection(SolutionProperties) = preSolution
20 26
 		HideSolutionNode = FALSE