crypto library

Native AES-CTR with a Dart fallback.

Classes

XCrypto
AES-256-CTR backed by the platform's hardware-accelerated crypto — Android javax.crypto (Conscrypt/BoringSSL → ARMv8 AES instructions), Apple CommonCrypto, Windows CNG (AES-ECB over the counter blocks → AES-NI) — with a transparent pure-Dart fallback (encryptChunk) where no native handler ships (web / linux / unit tests). The bytes are encrypted as if a single continuous CTR stream whose initial counter block is iv had already processed pos plaintext bytes; CTR is symmetric, so the same call also decrypts. Native and fallback are byte-for-byte identical — the cross-engine parity tests are the guard.

Functions

encryptChunk(Uint8List key, Uint8List baseIv, int pos, Uint8List plain) → Uint8List
Encrypts plain under AES-256-CTR with key and base counter block baseIv, producing the keystream bytes that a streaming cipher initialised at offset 0 would produce at byte positions [pos, pos + plain.length).