symmetric static method
Creates a symmetric cipher based on the given algorithm.
algorithm: The symmetric cipher algorithm (AES, DES)
input: The complete input record with configuration
Returns: An instance of the specified symmetric cipher
Throws: ArgumentError if algorithm is not supported
Note: For ChaCha20, use the chacha20 factory method instead.
Implementation
static ISymmetricCipher symmetric(
CryptoAlgorithm algorithm,
InputSymmetricCipher input,
) {
return switch (algorithm) {
CryptoAlgorithm.aes => AESCipher.createFull(InputAESCipher(parent: input)),
CryptoAlgorithm.des => DESCipher.createFull(InputDESCipher(parent: input)),
CryptoAlgorithm.chacha20 => throw ArgumentError(
'Use chacha20() factory method for ChaCha20 cipher',
),
_ => throw ArgumentError('Not a symmetric cipher algorithm: $algorithm'),
};
}