- [C#] Viết ứng dụng Auto Fill list Textbox from clipboard Winform
- [TOOL] Chia sẻ phần mềm thay đổi thông tin cấu hình máy tính
- [C#] Hướng dẫn Export dữ liệu ra file Microsoft Word Template
- [C#] Chia sẻ source code tool kiểm tra domain website
- [C#] Hướng dẫn tạo file PDF sử dụng thư viện QuestPDF
- [C#] Hướng dẫn tạo ứng dụng dock windows giống Taskbar
- [C#] Chia sẻ source code sử dụng Object Listview trên Winform
- [VB.NET] Chia sẻ source code quản lý thu chi mô hình 3 lớp Winform
- [DATABASE] Xóa lịch sử danh sách đăng nhập tài khoản trên SMSS Sqlserver Management Studio
- [C#] Sử dụng FolderBrowserDialog Vista trên Winform
- [DEVEXPRESS] Chia sẻ tool Winform UI Templates Early Access Preview (EAP)
- [C#] Chia sẻ source code Spin Content (Trộn nội dung văn bản theo từ đồng nghĩa) trên Winform
- [VB.NET] Chia sẻ source code lịch âm dương và hẹn lịch nhắc việc
- [C#] Hướng dẫn đọc thông số thiết bị Thiết bị kiểm tra Pin (HIOKI BATTERY HiTESTER BT3562)
- [VB.NET] Hướng dẫn giải captcha sử dụng dịch vụ AZCaptcha API trên winform
- [C#] Hướng dẫn chứng thực đăng nhập ứng dụng bằng vân tay (Finger Print) trên máy tính
- [C#] Color Thief cách xuất màu sắc thiết kế từ hình ảnh
- [C#] Cách tạo bản quyền và cho phép dùng thử ứng dụng Winform
- [C#] Hướng dẫn sử dụng trình duyệt web Chrome convert HTML sang tập tin file PDF
- [C#] Kết nôi điện thoại Android, IOS với App Winform via Bluetooth
[C#] Mã hóa văn bản text sử dụng thuật toán AES Winform
Xin chào các bạn, bài viết hôm nay mình sẻ hướng dẫn các bạn mã hóa văn bản Text sử dụng thuật toán AES (Advanced Encryption Standard) trong winform.
[C#] AES cryptographic library for .NET Framework and .NET Core
Để sử dụng thuật toán này rất đơn giản, các bạn chỉ cần tải thư viện Rijndael256 AES từ Nuget Console về.
PM> Install-Package Rijndael256 -Version 3.2.0
Thư viện Rijndael256 AES hỗ trợ Keysizes: 128 bit, 192 bit và 256 bit.
Các bạn có thể sử dụng để mã hóa Text hoặc File.
Cú pháp sử dụng đơn giản:
string password = "sKzvYk#1Pn33!YN"; // Khóa để mã hóa
string plaintext = "Mã hóa thuật toán AES C# - laptrinhvb.net"; // Chuỗi cần mã hóa
// Mã hóa chuỗi
string ciphertext = Rijndael.Encrypt(plaintext, password, KeySize.Aes256);
// Giải mã chuỗi
plaintext = Rijndael.Decrypt(ciphertext, password, KeySize.Aes256);
Giao diện demo ứng dụng mã hóa AES C# Winform:
Source code sử dụng AES c#:
using Rijndael256;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace algorithmAES
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnEncrypt_Click(object sender, EventArgs e)
{
var inputText = txt_input.Text;
var key = txt_key.Text;
string EncryptText = Rijndael.Encrypt(inputText, key, KeySize.Aes256);
txt_encryptText.Text = EncryptText;
}
private void btnDecrypt_Click(object sender, EventArgs e)
{
var inputText = txt_encryptText.Text;
string key =txt_key.Text;
string DecryptText = Rijndael.Decrypt(inputText, key, KeySize.Aes256);
txt_DecryptText.Text = DecryptText;
}
}
}
Thanks for watching!