CryptoUtils class

加密和解密工具类

提供 MD5(字符串 / 文件)、SHA-256 摘要、HMAC-SHA1 / HMAC-SHA256 签名、 Base64 编解码、以及 XOR 对称加解密(含字节级 Base64 往返)。XOR 密钥为 逗号分隔的整数,非整数分段抛 ArgumentError。 依赖:crypto / convert(纯 Dart)。

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

decodeBase64(String data) → String
Base64解密字符串
encodeBase64(String data) → String
Base64加密字符串
encodeHmacSha1(String data, String secret, {bool base64 = false}) → String
HMAC-SHA1 签名:data 与 secret 均按 UTF-8 编码,默认返回小写 hex(40 字符);base64 为 true 时返回标准 base64。
encodeHmacSha256(String data, String secret, {bool base64 = false}) → String
HMAC-SHA256 签名:data 与 secret 均按 UTF-8 编码,默认返回小写 hex(64 字符);base64 为 true 时返回标准 base64。
encodeMd5(String data) → String
md5 加密字符串
encodeMd5File(File file) → String
md5 加密file
encodeSha256(String data) → String
sha256 摘要:输入按 UTF-8 编码,返回小写 hex(64 字符),与 encodeMd5 输出风格一致。
xorBase64Decode(String res, String key) → String
异或对称 Base64 解密
xorBase64Encode(String res, String key) → String
异或对称 Base64 加密
xorCode(String res, String key) → String
异或对称加密(按 UTF-16 码元;自反)。