using System;
using System.IO;
using System.Security.Cryptography;
public static class EncryptionHelper
{
private static byte[] key = new byte[32]; // 生成一个32字节的随机密钥
private static byte[] iv = new byte[16]; // 生成一个16字节的随机向量
public static byte[] Encrypt(byte[] data)
{
using (Aes 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))
{
csEncrypt.Write(data, 0, data.Length);
}
return msEncrypt.ToArray();
}
}
}
public static byte[] Decrypt(byte[] data)
{
using (Aes aes = Aes.Create())
{
aes.Key = key;
aes.IV = iv;
// 创建解密器并解密数据
ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
using (MemoryStream msDecrypt = new MemoryStream(data))
{
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
{
byte[] buffer = new byte[data.Length];
csDecrypt.Read(buffer, 0, buffer.Length);
return buffer;
}
}
}
}
}
绿盾?
和这个功能差不多的软件,可不是一两个人搞得定的,研发成本很高的!毕竟国内好几家公司就是靠开发、销售这种软件吃饭的。如果研发成本不高,难度不大,风险不高,这种软件早就烂大街了
看你的描述,似乎是公司自己用的,没打算开发成产品去卖。
如果是个demo,可能很快;如果要做个可靠的软件,这个不是十天半个月可以做出来的。