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(
  SymmetricCipherAlgorithm.aes,
  InputSymmetricCipher(
    parent: (...),
    key: AESCipher.generateKey(),
  ),
);

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

// Create signature
final hmac = CipherFactory.signature(
  SymmetricSignAlgorithm.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(AsymmetricCipherAlgorithm algorithm, InputAsymmetricCipher input) IAsymmetricCipher
Creates an asymmetric cipher based on the given algorithm.
asymmetricSign(AsymmetricSignAlgorithm algorithm, InputAsymmetricSign input) IAsymmetricSign
Creates an asymmetric signature instance based on the given algorithm.
chacha20(dynamic 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(SymmetricCipherAlgorithm algorithm, InputSymmetricCipher input) ISymmetricCipher
Creates a symmetric cipher based on the given algorithm.
symmetricSign(SymmetricSignAlgorithm algorithm, InputSymmetricSign input) ISymmetricSign
Creates a symmetric signature instance based on the given algorithm.