UEncryption class abstract
Hashes, encryption, key derivation and encoders, pure Dart on all 6 platforms. UEncryption.sha256Hash("hi")
Constructors
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
-
adler32(
String text) → int -
Adler-32 checksum as an int.
adler32("hi") -
aesDecrypt(
{required String base64Encrypted, required String key, required String iv, UAesMode mode = UAesMode.cbc, bool padding = true, UByteEncoding keyEncoding = UByteEncoding.utf8, UByteEncoding ivEncoding = UByteEncoding.utf8}) → String -
Reverses aesEncrypt with the same key, IV and mode.
aesDecrypt(base64Encrypted: c, key: k, iv: iv) -
aesEncrypt(
{required String plainText, required String key, required String iv, UAesMode mode = UAesMode.cbc, bool padding = true, UByteEncoding keyEncoding = UByteEncoding.utf8, UByteEncoding ivEncoding = UByteEncoding.utf8}) → String -
AES in any mode (CBC by default); key 16/24/32 chars, IV 16 chars; base64 out.
aesEncrypt(plainText: "x", key: "32-char-key...", iv: "16-char-iv......") -
ascii85DecodeText(
String value) → String -
Ascii85 → text.
ascii85DecodeText(value) -
ascii85EncodeText(
String text) → String -
Text → Ascii85.
ascii85EncodeText("hi") -
base32Decode(
String input) → List< int> -
Base32 → bytes (ignores spaces and padding).
base32Decode("JBSWY3DP") -
base32DecodeText(
String value) → String -
Base32 → text.
base32DecodeText("NBUQ====")→ "hi" -
base32Encode(
List< int> bytes) → String -
Bytes → Base32.
base32Encode(bytes) -
base32EncodeText(
String text) → String -
Text → Base32 (RFC 4648, used by 2FA secrets).
base32EncodeText("hi") -
base32HexDecodeText(
String value) → String -
Base32hex → text.
base32HexDecodeText(value) -
base32HexEncodeText(
String text) → String -
Text → Base32hex (sort-preserving alphabet).
base32HexEncodeText("hi") -
base45DecodeText(
String value) → String -
Base45 → text.
base45DecodeText(value) -
base45EncodeText(
String text) → String -
Text → Base45 (QR-friendly, used by EU health certificates).
base45EncodeText("hi") -
base58Check(
List< int> payload) → String -
Base58Check (payload + 4-byte double-SHA256 checksum).
base58Check(payload) -
base58Decode(
String value) → List< int> -
Base58 → bytes.
base58Decode("3yZe") -
base58DecodeText(
String value) → String -
Base58 → text.
base58DecodeText(value) -
base58Encode(
List< int> bytes) → String -
Bytes → Base58 (Bitcoin alphabet).
base58Encode(bytes) -
base58EncodeText(
String text) → String -
Text → Base58.
base58EncodeText("hi") -
base64DecodeText(
String value) → String -
Base64 → text.
base64DecodeText("aGk=")→ "hi" -
base64EncodeText(
String text) → String -
Text → base64.
base64EncodeText("hi")→ "aGk=" -
base64UrlDecodeText(
String value) → String -
URL-safe base64 → text.
base64UrlDecodeText(value) -
base64UrlEncodeText(
String text) → String -
Text → URL-safe base64 (- and _ instead of + and /).
base64UrlEncodeText("hi?") -
blake2bHash(
String text, {int bytes = 64}) → String -
BLAKE2b hex, 1-64 bytes.
blake2bHash("hi", bytes: 32) -
caesarShift(
String text, int shift) → String -
Shifts letters by
shiftplaces.caesarShift("abc", 1)→ "bcd" -
chacha20Decrypt(
{required String base64Encrypted, required String key, required String nonce, UByteEncoding keyEncoding = UByteEncoding.utf8, UByteEncoding nonceEncoding = UByteEncoding.utf8}) → String -
Reverses chacha20Encrypt.
chacha20Decrypt(base64Encrypted: c, key: k, nonce: n) -
chacha20Encrypt(
{required String plainText, required String key, required String nonce, UByteEncoding keyEncoding = UByteEncoding.utf8, UByteEncoding nonceEncoding = UByteEncoding.utf8}) → String -
ChaCha20 stream cipher (no tamper check); key 32 bytes, nonce 12 bytes.
chacha20Encrypt(plainText: "x", key: k, nonce: n) -
chacha20Poly1305Decrypt(
{required String base64Cipher, required String key, String? aad, UByteEncoding keyEncoding = UByteEncoding.base64}) → String -
Decrypts chacha20Poly1305Encrypt output; throws if tampered.
chacha20Poly1305Decrypt(base64Cipher: c, key: key) -
chacha20Poly1305Encrypt(
{required String plainText, required String key, String? aad, UByteEncoding keyEncoding = UByteEncoding.base64}) → String -
Tamper-proof encryption with ChaCha20-Poly1305 (fast on phones without AES hardware); base64 out.
chacha20Poly1305Encrypt(plainText: "x", key: UEncryption.randomKey()) -
constantTimeEquals(
String a, String b) → bool -
Compares two secrets without leaking timing.
constantTimeEquals(sentMac, expectedMac) -
crc16(
String text) → int -
CRC-16 checksum as an int.
crc16("hi") -
crc32(
String text) → int -
CRC-32 checksum as an int (zip/png style).
crc32("hi") -
decryptUint8List(
{required String base64Encrypted, required String key, required String iv}) → Uint8List -
Reverses encryptUint8List back to bytes.
decryptUint8List(base64Encrypted: c, key: k, iv: iv) -
encryptUint8List(
{required Uint8List data, required String key, required String iv}) → String -
AES-256-CBC for raw bytes; key must be 32 chars and IV 16 chars; base64 out.
encryptUint8List(data: bytes, key: k, iv: iv) -
fernetDecrypt(
{required String base64Encrypted, required String key, UByteEncoding keyEncoding = UByteEncoding.base64}) → String -
Reads a Fernet token; throws if tampered.
fernetDecrypt(base64Encrypted: token, key: key) -
fernetEncrypt(
{required String plainText, required String key, UByteEncoding keyEncoding = UByteEncoding.base64}) → String -
Fernet token (Python cryptography compatible); key is 32 bytes base64.
fernetEncrypt(plainText: "x", key: UEncryption.randomKey()) -
fnv1a32(
String text) → int -
FNV-1a 32-bit hash as an int (fast, stable across runs).
fnv1a32("hi") -
hexDecodeText(
String value) → String -
Hex → text.
hexDecodeText("6869")→ "hi" -
hexEncode(
List< int> bytes) → String -
Bytes → hex.
hexEncode([255, 1])→ "ff01" -
hexEncodeText(
String text) → String -
Text → hex.
hexEncodeText("hi")→ "6869" -
hexToBytes(
String hex) → List< int> -
Hex → bytes.
hexToBytes("ff01")→255, 1 -
hkdf(
{required String secret, String salt = "", String info = "", int length = 32, bool asHex = false}) → String -
Derives a key from a strong secret with HKDF-SHA256.
hkdf(secret: sharedSecret, info: "chat") -
hmacSha1(
String text, String key) → String -
HMAC-SHA1 hex (TOTP and old APIs).
hmacSha1(text, key) -
hmacSha256(
String text, String key) → String -
HMAC-SHA256 hex, e.g. to sign API requests.
hmacSha256(body, secret) -
hmacSha256Bytes(
List< int> data, List<int> key) → Uint8List -
HMAC-SHA256 of bytes, as bytes.
hmacSha256Bytes(data, key) -
hmacSha512(
String text, String key) → String -
HMAC-SHA512 hex.
hmacSha512(body, secret) -
keccak256Hash(
String text) → String -
Keccak-256 hex (Ethereum style, not SHA-3).
keccak256Hash("hi") -
md4Hash(
String text) → String -
MD4 hex (legacy only).
md4Hash("hi") -
md5Hash(
String text) → String -
MD5 hex (checksums only, not for passwords).
md5Hash("hi") -
morseDecode(
String code) → String -
Morse code → text.
morseDecode("... --- ...")→ "SOS" -
morseEncode(
String text) → String -
Text → Morse code.
morseEncode("SOS")→ "... --- ..." -
open(
{required String base64Cipher, required String key, String? aad, UByteEncoding keyEncoding = UByteEncoding.base64}) → String -
Decrypts what seal() made; throws if the data or key is wrong.
UEncryption.open(base64Cipher: sealed, key: key) -
pbkdf2(
{required String password, required String salt, int iterations = 100000, int length = 32, UByteEncoding saltEncoding = UByteEncoding.utf8, bool asHex = false}) → String -
Turns a password into a key with PBKDF2-SHA256 (slow on purpose).
pbkdf2(password: "1234", salt: "user@x.com") -
randomBytes(
int length) → Uint8List -
Secure random bytes.
randomBytes(16) -
randomHex(
{int bytes = 16}) → String -
Random hex string, e.g. for tokens (16 bytes = 32 chars).
randomHex(bytes: 8) -
randomIv(
{int bytes = 16}) → String -
New random 16-byte IV as base64.
randomIv() -
randomKey(
{int bytes = 32}) → String -
New random 32-byte key as base64, ready for seal().
final String key = UEncryption.randomKey(); -
rc4Decrypt(
{required String base64Encrypted, required String key, UByteEncoding keyEncoding = UByteEncoding.utf8}) → String -
Reverses rc4Encrypt.
rc4Decrypt(base64Encrypted: c, key: "k") -
rc4Encrypt(
{required String plainText, required String key, UByteEncoding keyEncoding = UByteEncoding.utf8}) → String -
RC4 (broken, only for talking to old systems); base64 out.
rc4Encrypt(plainText: "x", key: "k") -
ripemd160Hash(
String text) → String -
RIPEMD-160 hex.
ripemd160Hash("hi") -
rot13(
String text) → String -
Rotates letters by 13 (applying twice gives the original).
rot13("abc")→ "nop" -
rot47(
String text) → String -
Rotates printable ASCII by 47 (applying twice gives the original).
rot47("Hi!") -
salsa20Decrypt(
{required String base64Encrypted, required String key, required String iv, UByteEncoding keyEncoding = UByteEncoding.utf8, UByteEncoding ivEncoding = UByteEncoding.utf8}) → String -
Reverses salsa20Encrypt.
salsa20Decrypt(base64Encrypted: c, key: k, iv: iv) -
salsa20Encrypt(
{required String plainText, required String key, required String iv, UByteEncoding keyEncoding = UByteEncoding.utf8, UByteEncoding ivEncoding = UByteEncoding.utf8}) → String -
Salsa20 stream cipher (no tamper check); key 32 bytes, IV 8 bytes.
salsa20Encrypt(plainText: "x", key: k, iv: "8bytesiv") -
scrypt(
{required String password, required String salt, int n = 16384, int r = 8, int p = 1, int dkLen = 32, UByteEncoding saltEncoding = UByteEncoding.utf8, bool asHex = false}) → String -
Password → key with scrypt (memory-hard, slow on purpose).
scrypt(password: "1234", salt: "salt") -
seal(
{required String plainText, required String key, String? aad, UByteEncoding keyEncoding = UByteEncoding.base64}) → String -
Encrypts text with AES-256-GCM (tamper-proof, the one to use); returns base64.
UEncryption.seal(plainText: "secret", key: UEncryption.randomKey()) -
sha1Bytes(
List< int> data) → Uint8List -
SHA-1 of bytes, as bytes.
sha1Bytes(data) -
sha1Hash(
String text) → String -
SHA-1 hex (legacy checksums only).
sha1Hash("hi") -
sha224Hash(
String text) → String -
SHA-224 hex.
sha224Hash("hi") -
sha256Bytes(
List< int> data) → Uint8List -
SHA-256 of bytes, as bytes.
sha256Bytes(data) -
sha256Hash(
String text) → String -
SHA-256 hex, the usual choice.
sha256Hash("hi") -
sha3(
String text, {int bits = 256}) → String -
SHA-3 hex; bits 224/256/384/512.
sha3("hi", bits: 512) -
sha384Hash(
String text) → String -
SHA-384 hex.
sha384Hash("hi") -
sha512256Hash(
String text) → String -
SHA-512/256 hex.
sha512256Hash("hi") -
sha512Hash(
String text) → String -
SHA-512 hex.
sha512Hash("hi") -
shake128(
String text, {int bytes = 32}) → String -
SHAKE128 hex of any length.
shake128("hi", bytes: 16) -
shake256(
String text, {int bytes = 64}) → String -
SHAKE256 hex of any length.
shake256("hi", bytes: 32) -
sm3Hash(
String text) → String -
SM3 hex (Chinese national standard).
sm3Hash("hi") -
urlDecode(
String value) → String -
Un-escapes URL text.
urlDecode("a%20b")→ "a b" -
urlEncode(
String text) → String -
Escapes text for a URL.
urlEncode("a b")→ "a%20b" -
xchacha20Poly1305Decrypt(
{required String base64Cipher, required String key, String? aad, UByteEncoding keyEncoding = UByteEncoding.base64}) → String -
Reverses xchacha20Poly1305Encrypt; throws if tampered.
xchacha20Poly1305Decrypt(base64Cipher: c, key: key) -
xchacha20Poly1305Encrypt(
{required String plainText, required String key, String? aad, UByteEncoding keyEncoding = UByteEncoding.base64}) → String -
Tamper-proof XChaCha20-Poly1305 with a 24-byte random nonce; base64 out.
xchacha20Poly1305Encrypt(plainText: "x", key: key) -
xorDecrypt(
{required String base64Encrypted, required String key, UByteEncoding keyEncoding = UByteEncoding.utf8}) → String -
Reverses xorEncrypt.
xorDecrypt(base64Encrypted: c, key: "k") -
xorEncrypt(
{required String plainText, required String key, UByteEncoding keyEncoding = UByteEncoding.utf8}) → String -
XOR with a repeating key (obfuscation, not security); base64 out.
xorEncrypt(plainText: "x", key: "k")