使用C#自带的AES加密算法,封装加密与解密方法
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using UnityEngine;
public class EncryptionHelper : SingltonManager<EncryptionHelper>
{
/// <summary>
/// 获取密钥
/// </summary>
public string Key
{
get { return @")O[NB]6,YF}+efcaj{+oESb9d8>Z'e9M"; }
}
/// <summary>
/// 获取向量
/// </summary>
public string IV
{
get { return @"L+\~f4,Ir)b$=pkf"; }
}
/// <summary>
/// AES加密
/// </summary>
/// <param name="plainStr">明文字符串</param>
/// <returns>密文</returns>
public string AESEncrypt(string plainStr)
{
byte[] bKey = Encoding.UTF8.GetBytes(Key);
byte[] bIV = Encoding.UTF8.GetBytes(IV);