fromAlgorithm static method
Creates a cipher/signature instance from a generic algorithm type.
This is a convenience method that dispatches to the appropriate factory method based on the algorithm's runtime type.
Note: For asymmetric operations, ensure you pass the correct Input type that matches your algorithm.
Implementation
static dynamic fromAlgorithm(
CryptoAlgorithm algorithm,
dynamic input,
) {
if (algorithm is SymmetricCipherAlgorithm) {
return symmetric(algorithm, input as InputSymmetricCipher);
} else if (algorithm is AsymmetricCipherAlgorithm) {
return asymmetric(algorithm, input as InputAsymmetricCipher);
} else if (algorithm is SymmetricSignAlgorithm) {
return symmetricSign(algorithm, input as InputSymmetricSign);
} else if (algorithm is AsymmetricSignAlgorithm) {
return asymmetricSign(algorithm, input as InputAsymmetricSign);
} else {
throw ArgumentError('Unsupported algorithm type: $algorithm');
}
}