cipherlib library

Implementations of cryptographic algorithms for encryption and decryption in pure Dart.

Classes

AEADCipher<C extends Cipher, M extends MACHashBase<HashDigestSink>>
Provides support for AEAD (Authenticated Encryption with Associated Data) to the any Cipher with any MAC algorithm.
AEADResult
The result from AEAD ciphers
AEADResultWithIV
The result from AEAD ciphers having an IV or nonce
AEADStreamCipher<C extends StreamCipher, M extends MACHashBase<HashDigestSink>>
AEADStreamResult
The result from AEAD stream ciphers
AEADStreamResultWithIV
The result from AEAD stream ciphers having an IV or nonce
AES
AES (Advanced Encryption Standard) is a symmetric encryption algorithm used for securing data. It operates on fixed-size blocks of data (128 bits) using keys of 128, 192, or 256 bits.
AESCore
This implementation is based on NIST FIPS 197-upd1.
AESInCBCMode
Provides encryption and decryption for AES cipher in CBC mode.
AESInCBCModeDecrypt
Provides decryption for AES cipher in CBC mode.
AESInCBCModeEncrypt
Provides encryption for AES cipher in CBC mode.
AESInCFBMode
Provides encryption and decryption for AES cipher in CFB mode.
AESInCFBModeCipher
Provides encryption for AES cipher in CFB mode.
AESInCTRMode
Provides encryption and decryption for AES cipher in CTR mode.
AESInCTRModeCipher
Provides AES cipher in CTR mode.
AESInECBMode
Provides encryption and decryption for AES cipher in ECB mode.
AESInECBModeDecrypt
Provides decryption for AES cipher in ECB mode.
AESInECBModeEncrypt
Provides encryption for AES cipher in ECB mode.
AESInGCMMode
Provides encryption and decryption for AES cipher in GCM mode.
AESInGCMModeCipherCore
This implementation is derived from NIST GCM Specification.
AESInGCMModeDecrypt
Provides AES cipher in GCM mode for decryption.
AESInGCMModeEncrypt
Provides AES cipher in GCM mode for encryption.
AESInIGEMode
Provides encryption and decryption for AES cipher in IGE mode.
AESInIGEModeDecrypt
Provides decryption for AES cipher in IGE mode.
AESInIGEModeEncrypt
Provides encryption for AES cipher in IGE mode.
AESInOFBMode
Provides encryption and decryption for AES cipher in OFB mode.
AESInOFBModeCipher
Provides encryption for AES cipher in OFB mode.
AESInPCBCMode
Provides encryption and decryption for AES cipher in PCBC mode.
AESInPCBCModeDecrypt
Provides decryption for AES cipher in PCBC mode.
AESInPCBCModeEncrypt
Provides encryption for AES cipher in PCBC mode.
AESInXTSMode
Provides encryption and decryption for AES cipher in XTS mode.
AESInXTSModeDecrypt
Provides decryption for AES cipher in XTS mode.
AESInXTSModeEncrypt
Provides encryption for AES cipher in XTS mode.
ChaCha20
ChaCha20 is a stream cipher that uses a 256-bit key and a 64-bit nonce to generate a unique cipher stream for each messages.
ChaCha20Poly1305
ChaCha20-Poly1305 is a cryptographic algorithm combining ChaCha20 stream cipher for encryption and Poly1305 for generating message authentication code. It provides both confidentiality and integrity protection, making it a popular choice for secure communication protocols like TLS.
Cipher
Template for symmetric cipher algorithms that uses the same logic for both encryption and decryption.
CipherBase
Template for all Cipher algorithms in this package
CipherPair<E extends Cipher, D extends Cipher>
Template for symmetric cipher algorithms which does not use the same logic for both encryption and decryption.
Nonce
Random initialization vector builder.
Nonce128
The 128-bit initialization vector builder.
Nonce64
The 64-bit initialization vector builder.
Padding
Padding is a process to extend the input message to match a specific block size to be used in the cryptographic algorithms.
Salsa20
Salsa20 is a stream cipher that uses a 256-bit key and a 64-bit nonce to generate a unique cipher stream for each messages.
Salsa20Poly1305
Salsa20-Poly1305 is a cryptographic algorithm combining the Salsa20 stream cipher for encryption and the Poly1305 for generating message authentication code.
StreamCipher
Template for Cipher algorithm that uses the same logic for both encryption and decryption.
StreamCipherPair<E extends StreamCipher, D extends StreamCipher>
Template for symmetric cipher algorithms which does not use the same logic for both encryption and decryption.
XChaCha20
XChaCha20 is a stream cipher that uses a 256-bit key and a 192-bit nonce to generate a unique cipher stream for each messages.
XChaCha20Poly1305
XChaCha20-Poly1305 is a cryptographic algorithm combining XChaCha20 stream cipher for encryption and Poly1305 for generating message authentication code.
XOR
XOR (exclusive or) cipher is a simple and lightweight method of encrypting data. It is often used for basic data obfuscation.
XSalsa20
XSalsa20 is a stream cipher that uses a 256-bit key and a 256-bit nonce to generate a unique cipher stream for each messages.
XSalsa20Poly1305
XSalsa20-Poly1305 is a cryptographic algorithm combining the XSalsa20 stream cipher for encryption and the Poly1305 for generating message authentication code.

Mixins

SaltedCipher
Mixin to use a random initialization vector or salt with the Cipher

Extensions

ChaCha20ExtentionForPoly1305 on ChaCha20
Adds poly1305 to ChaCha20 to create an instance of ChaCha20Poly1305
Salsa20ExtentionForPoly1305 on Salsa20
Adds poly1305 to Salsa20 to create an instance of Salsa20Poly1305
StreamCipherExtension on StreamCipher
Provides support for streaming single byte values using a StreamCipher.
XChaCha20ExtentionForPoly1305 on XChaCha20
Adds poly1305 to XChaCha20 to create an instance of XChaCha20Poly1305
XSalsa20ExtentionForPoly1305 on XSalsa20
Adds poly1305 to XSalsa20 to create an instance of XSalsa20Poly1305

Functions

chacha20(List<int> message, List<int> key, {List<int>? nonce, Nonce64? counter}) Uint8List
Apply ChaCha20 cipher with the follwing parameters:
chacha20poly1305(List<int> message, List<int> key, {List<int>? mac, List<int>? nonce, List<int>? aad, Nonce64? counter}) AEADResultWithIV
Encrypts or Decrypts the message using ChaCha20 cipher and generates an authentication tag with Poly1305.
salsa20(List<int> message, List<int> key, {List<int>? nonce, Nonce64? counter}) Uint8List
Apply Salsa20 cipher with the follwing parameters:
salsa20poly1305(List<int> message, List<int> key, {List<int>? mac, List<int>? nonce, List<int>? aad, Nonce64? counter}) AEADResultWithIV
Encrypts or Decrypts the message using Salsa20 cipher and generates an authentication tag with Poly1305.
xchacha20(List<int> message, List<int> key, {List<int>? nonce, Nonce64? counter}) Uint8List
Apply XChaCha20 cipher with the follwing parameters:
xchacha20poly1305(List<int> message, List<int> key, {List<int>? mac, List<int>? nonce, List<int>? aad, Nonce64? counter}) AEADResultWithIV
Encrypts or Decrypts the message using XChaCha20 cipher and generates an authentication tag with Poly1305.
xor(List<int> message, List<int> key) Uint8List
Apply XOR cipher to the message using the key.
xsalsa20(List<int> message, List<int> key, {List<int>? nonce, Nonce64? counter}) Uint8List
Apply XSalsa20 cipher with the follwing parameters:
xsalsa20poly1305(List<int> message, List<int> key, {List<int>? mac, List<int>? nonce, List<int>? aad, Nonce64? counter}) AEADResultWithIV
Encrypts or Decrypts the message using XSalsa20 cipher and generates an authentication tag with Poly1305.