How To Code An AES Text Encryption Program Application In C# NET
Hope you all enjoy the video. Sorry it is a little chopped as showing me typing all of the code would have resulted in the video being an hour long. Here is the source code:
Encryptor class:
using Microsoft.SqlServer.Server;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace EncForTurorial
{
class Encryptor
{
public static string IV = "1a1a1a1a1a1a1a1a";
public static string Key = "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a13";
public static string Encrypt(string decrypted)
{
byte[] textBytes = ASCIIEncoding.ASCII.GetBytes(decrypted);
AesCryptoServiceProvider endec = new AesCryptoServiceProvider(); ;
endec.BlockSize = 128;
endec.KeySize = 256;
endec.IV = ASCIIEncoding.ASCII.GetBytes(IV);
endec.Key = ASCIIEncoding.ASCII.GetBytes(Key);
endec.Padding = PaddingMode.PKCS7;
endec.Mode = CipherMode.CBC;
ICryptoTransform icrypt = endec.CreateEncryptor(endec.Key, endec.IV);
byte[] enc = icrypt.TransformFinalBlock(textBytes, 0, textBytes.Length);
icrypt.Dispose();
return Convert.ToBase64String(enc);
}
public static string Decrypted(string encrypted)
{
var check = Form1.verify;
string password = Form1.password;
if (check == password)
{
byte[] textbytes = Convert.FromBase64String(encrypted);
AesCryptoServiceProvider endec = new AesCryptoServiceProvider();
endec.BlockSize = 128;
endec.KeySize = 256;
endec.IV = ASCIIEncoding.ASCII.GetBytes(IV);
endec.Key = ASCIIEncoding.ASCII.GetBytes(Key);
endec.Padding = PaddingMode.PKCS7;
endec.Mode = CipherMode.CBC;
ICryptoTransform icrypt = endec.CreateDecryptor(endec.Key, endec.IV);
byte[] enc = icrypt.TransformFinalBlock(textbytes, 0, textbytes.Length);
icrypt.Dispose();
if (Form1.verify == password)
{
return System.Text.ASCIIEncoding.ASCII.GetString(enc);
}
else if (Form1.verify != password)
{
MessageBox.Show("Please use the original key file.");
}
}
return encrypted;
}
}
}
Code for Form1:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace EncForTurorial
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
public static string password;
private void button1_Click(object sender, EventArgs e)
{
password = textBox1.Text;
string encm = Encryptor.Encrypt(richTextBox1.Text);
System.IO.File.WriteAllText(@"C:\\privatemessage.txt", encm);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
password = textBox1.Text;
}
private void button2_Click(object sender, EventArgs e)
{
StreamReader sr = new StreamReader(@"C:\\privatemessage.txt");
string line = sr.ReadLine();
richTextBox1.Text = Encryptor.Decrypted(Convert.ToString(line));
}
public static string verify;
private void textBox2_TextChanged(object sender, EventArgs e)
{
verify = textBox2.Text;
}
}
}
c# guitar chord,
c# generics,
c# game programming,
c# guitar tuning,
c# get set,
c# game development,
g#c#f#bd#g#,
c#g#c#f#g#c#,
my sir g c#,
c#g#d#g#cd# tuning,
c# healing frequency,
c# hello world,
c# httpclient,
c# hash table,
c# harmonic minor,
c# hotel management system,
c# hashset,
c# history,
c# interface,
c# interview,
c# inheritance,
c# in unity,
c# intermediate,
c# interview questions,
c# in visual studio code,
c# intermediate tutorial,
c# json,
c# jobs,
c# jazz chords,
c# jam track,
c# java,
c# json tutorial,
c# jwt,
c# jagged array,
j extybt c#,
equinoxe c#- (j.coltrane),
c# kudvenkat,
c# khmer,
c# key,
c# keylogger,
c# keywords,
c# keyboard,
c# kurdish,
c# kafka,
k team c#,
camp r.k.c#309,
r.k.c#309,
k.a.c#252,
c# linq,
c# lambda,
c# list,
c# login form,
c# loops,
c# learning,
c# linked list,
c# lambda expression,
c# minor,
c# major backing track,
c# minor scale,
c# major,
c# methods,
c# mvc,
c# multithreading,
f\
Other Videos By Wassup2190 Tech Tutorials Tricks Computers
Other Statistics
Counter-Strike: Source Statistics For Wassup2190 Tech Tutorials Tricks Computers
Wassup2190 Tech Tutorials Tricks Computers currently has 37,975 views spread across 2 videos for Counter-Strike: Source. Less than an hour worth of Counter-Strike: Source videos were uploaded to his channel, making up less than 0.83% of the total overall content on Wassup2190 Tech Tutorials Tricks Computers's YouTube channel.