Skip to content

Class AES

Namespace: Tool.Utils.Encryption
Assembly: Tool.Net.dll

AES 加密 解密,秘钥长度为32位,不足时系统自动补足空字符。

csharp
public sealed class AES

Inheritance

objectAES

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods

ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)

Remarks

代码由逆血提供支持

Fields

Keys

对称算法, 65, 114, 101, 121, 111, 117, 109, 121, 83, 110, 111, 119, 109, 97, 110, 63

csharp
public static readonly byte[] Keys

Field Value

byte[]

Methods

Decrypt(string, string)

解密成字符串

csharp
public static string Decrypt(string cipherText, string cipherkey)

Parameters

cipherText string

密文

cipherkey string

密码密钥

Returns

string

返回字符串

DecryptBuffer(byte[], string)

解密byte[]

csharp
public static byte[] DecryptBuffer(byte[] cipherText, string cipherkey)

Parameters

cipherText byte[]

密文内容

cipherkey string

密码密钥

Returns

byte[]

Encrypt(string, string)

加密字符串

csharp
public static string Encrypt(string plainText, string cipherkey)

Parameters

plainText string

原字符串

cipherkey string

密码密钥

Returns

string

返回加密的字符串

EncryptBuffer(byte[], string)

加密byte[]

csharp
public static byte[] EncryptBuffer(byte[] plainText, string cipherkey)

Parameters

plainText byte[]

原内容

cipherkey string

密码密钥

Returns

byte[]

GetPassword(string)

获取AES实际加密密码

csharp
public static string GetPassword(string encryptKey)

Parameters

encryptKey string

原密码密钥

Returns

string

基于Apache-2.0协议开源