- [DEVEXPRESS] Hướng dẫn bật tính năng Scroll Pixcel in Touch trên GridView
- [DEVEXPRESS] Hướng dẫn sử dụng TileBar viết ứng dụng duyệt hình ảnh Winform
- [DEVEXPRESS] Tô màu border TextEdit trên Winform
- [C#] Lấy dữ liệu từ Console Write hiển thị lên textbox Winform
- [C#] Hiển thị Progress bar trên Window Console
- [C#] Di chuyển control Runtime và lưu layout trên winform
- [SQLSERVER] Sử dụng hàm NULL IF
- [C#] Chia sẽ source code mã đi tuần bằng giao diện Winform
- [C#] Flash Window in Taskbar Winform
- Download và Giải nén tập tin File sử dụng Powershell
- [C#] Hướng dẫn cách lấy thông tin đăng nhập tài khoản và mật khẩu web browser trên windows
- [VB.NET] CRUD Thêm xóa sửa tìm kiếm Realtime FireBase
- [C#] Hiển thị thông báo Toast Message trong lập trình Winform
- [C#] Cấu hình định dạng ngày tháng, thời gian trên Windows cho ứng dụng Winform
- [C#] Rút gọn đường dẫn link url với TinyURL API
- [C#] Hướng dẫn cách bo tròn winform with Radius
- [C#] Chia sẽ class BackGroundOverlay Show Modal cho Winform
- [C#] Hướng dẫn Flip Image Winform
- [C#] Invoke là gì? cách sử dụng phương thức Invoke()
- [C#] Hướng dẫn chia sẽ file, folder từ ứng dụng sang Zalo Chat
[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!