CipherFactory class

Central factory for creating cipher, signature, and key exchange instances.

This factory provides a centralized way to instantiate cryptographic objects based on algorithm enums. It eliminates the need to remember specific class names and provides a consistent API across all cipher types.

Usage

// Create symmetric cipher
final aes = CipherFactory.symmetric(
  SymmetricCipherAlgorithmEnum.aes,
  InputSymmetricCipher(
    parent: (...),
    key: AESCipher.generateKey(),
  ),
);

// Create asymmetric cipher
final rsa = CipherFactory.asymmetric(
  AsymmetricCipherAlgorithmEnum.rsa,
  InputAsymmetricCipher(
    parent: (...),
    publicKey: '...',
    privateKey: '...',
  ),
);

// Create signature
final hmac = CipherFactory.symmetricSign(
  SymmetricSignAlgorithmEnum.hmac,
  InputSymmetricSign(
    parent: (...),
    key: HMACSign.generateKey(),
  ),
);
Annotations
  • @includeInBarrelFile

Constructors

CipherFactory()

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

asymmetric(CryptoAlgorithm algorithm, InputAsymmetricCipher input) → IAsymmetricCipher
Creates an asymmetric cipher based on the given algorithm.
asymmetricSign(CryptoAlgorithm algorithm, InputAsymmetricSign input) → IAsymmetricSign
Creates an asymmetric signature instance based on the given algorithm.
chacha20(InputChaCha20Cipher input) → ISymmetricCipher
Creates a ChaCha20 cipher with a nonce.
ecdh(dynamic input) → IKeyExchange
Creates an ECDH key exchange instance.
fromAlgorithm(CryptoAlgorithm algorithm, dynamic input) → dynamic
Creates a cipher/signature instance from a generic algorithm type.
symmetric(CryptoAlgorithm algorithm, InputSymmetricCipher input) → ISymmetricCipher
Creates a symmetric cipher based on the given algorithm.
symmetricSign(CryptoAlgorithm algorithm, InputSymmetricSign input) → ISymmetricSign
Creates a symmetric signature instance based on the given algorithm.