'Get IV size for a specific cipher in node.js

Is there a way to get the IV size for a specific cipher, like what is returned by a call to OpenSSL's EVP_CIPHER_CTX_iv_length()?

If an IV has the wrong size, cypto.createCipheriv() will return an error, but there does not seem to exist a function returning the right size before attempting to create a cipher based on an IV.



Solution 1:[1]

Starting from node v15, one can use getCipherInfo :

crypto.getCipherInfo(cipher).ivLength

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bunch