Crypto Class

提供 AES对称加密/解密、Hash生成/验证、签名以及其它辅助方法 的工具类。

Definition

Namespace: QuickAdmin.Utils
Assembly: QuickAdmin.Net (in QuickAdmin.Net.dll) Version: 1.1.6
C#
public class Crypto
Inheritance
object    Crypto
Derived

Constructors

CryptoInitializes a new instance of the Crypto class

Properties

Public Properties

DefaultCryptoKey 获取/设置加密、解密用默认密钥。

Methods

Public Methods

BytesToHexString 将字节数组转为对应的十六进制格式字符串。
ComputeFileHash 计算指定文件的哈希值。
ComputeHash(byte, CryptoHashType, bool) 计算指定字节数组的哈希值。
ComputeHash(string, CryptoHashType, bool) 计算指定字符串的哈希值。
DecryptBuffer(byte, bool) 使用默认密钥 DefaultCryptoKey 解密字节数组。
DecryptBuffer(byte, CryptoCryptoKey, bool) 使用指定密钥解密字节数组。
DecryptBuffer(byte, string, bool) 使用指定密钥 Key 解密字节数组。
DecryptString(string, bool) 使用默认密钥 DefaultCryptoKey 解密字符串。
DecryptString(string, CryptoCryptoKey, bool) 使用指定密钥解密字符串。
DecryptString(string, string, bool) 使用指定密钥 Key 解密字符串。
DecryptStringFromBytes(byte, bool) 将加密后的字节数组使用默认密钥 DefaultCryptoKey 解密为字符串。
DecryptStringFromBytes(byte, CryptoCryptoKey, bool) 将加密后的字节数组使用指定密钥解密为字符串。
DecryptStringFromBytes(byte, string, bool) 将加密后的字节数组使用指定密钥 Key 解密为字符串。
EncryptBuffer(byte, bool) 使用默认密钥 DefaultCryptoKey 加密字节数组。
EncryptBuffer(byte, CryptoCryptoKey, bool) 使用指定密钥加密字节数组。
EncryptBuffer(byte, string, bool) 使用指定密钥 Key 加密字节数组。
EncryptString(string, bool) 使用默认密钥 DefaultCryptoKey 加密字符串。
EncryptString(string, CryptoCryptoKey, bool) 使用指定密钥加密字符串。
EncryptString(string, string, bool) 使用指定密钥 Key 加密字符串。
EncryptStringToBytes(string, bool) 使用默认密钥 DefaultCryptoKey 加密字符串,并返回加密后的字节数组。
EncryptStringToBytes(string, CryptoCryptoKey, bool) 使用指定密钥加密字符串,并返回加密后的字节数组。
EncryptStringToBytes(string, string, bool) 使用指定密钥 Key 加密字符串,并返回加密后的字节数组。
GenerateCryptoKey 生成一个随机密钥。
GenerateIV 生成一个随机初始化向量 IV 并返回其用 base64 编码后的字符串值。
GenerateIVBytes 生成一个随机初始化向量 IV 并返回其二进制值。
GenerateKey 生成一个随机密钥 Key 并返回其用 base64 编码后的字符串值。
GenerateKeyBytes 生成一个随机密钥 Key 并返回其二进制值。
GenerateRandomBase64String 生成随机 base64 编码字符串。
GenerateRandomBytes 生成随机字节数据。
HashPbkdf2(string, byte, int, int) 使用指定的 salt 值,然后用 PBKDF2 算法对密码进行哈希处理。示例参见 HashPbkdf2AndReturnBase64SaltDotHash(string, int, int, int)
HashPbkdf2(string, string, int, int) 使用指定的 base64 salt 值,然后用 PBKDF2 算法对密码进行哈希处理。示例参见 HashPbkdf2AndReturnBase64SaltDotHash(string, int, int, int)
HashPbkdf2AndReturnBase64SaltDotHash 使用随机 salt 值,然后用 PBKDF2 算法对密码进行哈希处理并同时返回所用 salt 以及哈希值。
HexStringToBytes 将十六进制格式字符串转为对应的字节数组。
RawSignData 使用指定的密钥数据及哈希值类型签名字节数据。
RawVerifySignature 验证字节数据签名。
SignData 使用指定的密钥字符串及哈希值类型签名字符串数据。
VerifyFileHash 验证指定文件的哈希值。
VerifyHash(byte, string, CryptoHashType) 验证指定字节数组的哈希值。
VerifyHash(string, string, CryptoHashType) 验证指定字符串的哈希值。
VerifyHashPbkdf2(string, string, int) 验证用 HashPbkdf2AndReturnBase64SaltDotHash(string, int, int, int) 生成的密码哈希值。
VerifyHashPbkdf2(string, byte, string, int) 指定 salt 值,验证用 HashPbkdf2 生成的密码哈希值。示例参见 HashPbkdf2AndReturnBase64SaltDotHash(string, int, int, int)
VerifyHashPbkdf2(string, string, string, int) 指定 base64 salt 值,验证用 HashPbkdf2 生成的密码哈希值。示例参见 HashPbkdf2AndReturnBase64SaltDotHash(string, int, int, int)
VerifySignature 验证字符串签名。

See Also