CryptoUtils class

Constructors

CryptoUtils()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

decryptAES({required String encryptedData, required String userKey}) String
AES-256-GCM解密
decryptFast({required String encryptedData, required String userKey}) String
快速解密
deriveKey({required String password, required Uint8List salt, int keyLength = 32}) Uint8List
PBKDF2密钥派生 - 从密码生成加密密钥
encryptAES({required String plainText, required String userKey}) String
AES-256-GCM加密 - 用于SharedPreferences 提供认证加密,防止数据篡改
encryptFast({required String plainText, required String userKey}) String
快速加密(使用AES-CTR模式,适合大数据)
generateInstallationSalt() String
生成安装时的唯一盐值(应该在首次安装时生成并保存)
generateTimeBasedKey({required String baseKey, Duration validity = const Duration(hours: 1)}) String
生成时间戳基础的动态密钥(可选,用于额外安全)
generateUserKey({required String userId, required String deviceId, String? additionalEntropy}) String
从用户特定信息生成密钥 组合多个因素确保每个用户的密钥唯一