[Encryption] Improve cipher detection

The original way to detect cipher by name is a little complicated and unsafe, since the function will raise a segment fault when the required cipher not available in OpenSSL library. This pull request adds some code to check the result of `EVP_get_cipherbyname ` to avoid this issue.