Learn How to Build a Secure AES Text Encryption App in C# .NET πŸ”

Discover step-by-step instructions to create a robust AES encryption program in C# .NET. Perfect for securing your text data effortlessly!

Learn How to Build a Secure AES Text Encryption App in C# .NET πŸ”
Wassup2190 Tech Tutorials Tricks Computers
4.1K views β€’ Sep 30, 2020
Learn How to Build a Secure AES Text Encryption App in C# .NET πŸ”

About this video

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\

Tags and Topics

Browse our collection to discover more content in these categories.

Video Information

Views

4.1K

Likes

49

Duration

18:42

Published

Sep 30, 2020

User Reviews

4.4
(4)
Rate:

Related Trending Topics

LIVE TRENDS

Related trending topics. Click any trend to explore more videos.