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 ...
๐ฅ Related Trending Topics
LIVE TRENDSThis video may be related to current global trending topics. Click any trend to explore more videos about what's hot right now!
THIS VIDEO IS TRENDING!
This video is currently trending in Turkey under the topic 'bursa deprem'.
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\
Video Information
Views
4.1K
Total views since publication
Likes
49
User likes and reactions
Duration
18:42
Video length
Published
Sep 30, 2020
Release date
Quality
hd
Video definition
About the Channel
Tags and Topics
This video is tagged with the following topics. Click any tag to explore more related content and discover similar videos:
#c# #c# programming #learn c# #c# tutorial #c sharp tutorial #c# fundamentals for absolute beginners #c# course #c# for beginners #c# tutorial for beginners #c# (programming language) #.net #c# programming tutorial for beginners #learn c# for beginners #learn c# for unity #unity #learn c# in one video #learn c# programming #.net framework #c# training #csharp #csharp tutorial #c sharp #micrososft
Tags help categorize content and make it easier to find related videos. Browse our collection to discover more content in these categories.