How to Encrypt and Decrypt a String in C#
By FoxLearn 11/20/2024 1:09:05 PM 7.56K
It's particularly useful for scenarios like protecting sensitive data in Windows Forms applications.
Open Visual Studio, then click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "EncryptDecryptDemo" and then click OK
You can install the Eramake.eCryptography library via NuGet Package Manager
Right click on your project select Manage NuGet Packages -> Search eramake.ecryptography -> Install
Drag and drop the Label, TextBox and Button controls from Visual Toolbox onto your form designer, then you can design your form as shown below.
You can easily integrate this into a Windows Forms application by adding TextBox controls for input/output and Buttons for actions as shown below.
using System; using System.Windows.Forms; namespace EncryptDecryptDemo { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnEncrypt_Click(object sender, EventArgs e) { // Encrypt the input text txtEncrypt.Text = Eramake.eCryptography.Encrypt(txtValue.Text); } private void btnDecrypt_Click(object sender, EventArgs e) { // Decrypt the encrypted text txtDecrypt.Text = Eramake.eCryptography.Decrypt(txtEncrypt.Text); } } }
With these steps, you can easily encrypt and decrypt strings using the Eramake.eCryptography library in a C# Windows Forms application.
VIDEO TUTORIAL
- How to update UI from another thread in C#
- How to get CheckedListBox selected values in C#
- How to use Advanced Filter DataGridView in C#
- How to create a Notification Popup in C#
- How to Use Form Load and Button click Event in C#
- How to Link Chart /Graph with Database in C#
- How to Check SQL Server Connection in C#
- How to Generate Serial Key in C#