From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点
---
WPFProject/Utils/Encryptor.cs | 63 +++++++++++++++++++++++++++++++
1 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/WPFProject/Utils/Encryptor.cs b/WPFProject/Utils/Encryptor.cs
new file mode 100644
index 0000000..ab91d77
--- /dev/null
+++ b/WPFProject/Utils/Encryptor.cs
@@ -0,0 +1,63 @@
+锘縰sing System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace WPFProject.Utils
+{
+ public class Encryptor
+ {
+ private readonly byte[] key;
+ private readonly byte[] iv;
+
+ public Encryptor(string keyString, string ivString)
+ {
+ key = Encoding.UTF8.GetBytes(keyString);
+ iv = Encoding.UTF8.GetBytes(ivString);
+ }
+
+ public string Encrypt(string plainText)
+ {
+ using (var aes = Aes.Create())
+ {
+ aes.Key = key;
+ aes.IV = iv;
+ ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
+
+ using (MemoryStream msEncrypt = new MemoryStream())
+ {
+ using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
+ {
+ using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
+ {
+ swEncrypt.Write(plainText);
+ }
+ return Convert.ToBase64String(msEncrypt.ToArray());
+ }
+ }
+ }
+ }
+
+
+ public string Decrypt(string cipherText)
+ {
+ using (var aes = Aes.Create())
+ {
+ aes.Key = key;
+ aes.IV = iv;
+ ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
+ byte[] arr = Convert.FromBase64String(cipherText);
+ using (MemoryStream msDecrypt = new MemoryStream(arr))
+ {
+ using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
+ {
+ using (StreamReader srDecrypt = new StreamReader(csDecrypt))
+ {
+ return srDecrypt.ReadToEnd();
+ }
+ }
+ }
+ }
+ }
+ }
+}
--
Gitblit v1.9.1