I'm creating public packages, There are some encryption there, I let developer to choose cipher type and mode and set the key for encryption part of the packeges. Now I need to check the key size before using it in MCrypt functions. So what I have to know is:
1) All possible key sizes for the cipher.
2) Byte size of the given key.
Or if you have a better way, please share it.
mcrypt_list_algorithms()
gives you the list of ciphersmcrypt_module_get_supported_key_sizes($cipher)
gives you the supported key sizes (is empty if the keysizes are continous)mcrypt_module_get_algo_key_size($cipher)
gives you the maximum key size in case the previous function returned nothingAll key sizes are given in bytes.
Example:
Use
strlen($input)
to retrieve the bytes in a given string (should be decoded).