php8.5
Home/ Manual/ openssl / functions/ openssl_cipher_key_length

openssl_cipher_key_length

PHP function Edit on GitHub ✎

(PHP 8 >= 8.2.0)

Gets the cipher key length

Description

openssl_cipher_key_length(string $cipher_algo): int|false

Gets the cipher key length.

Parameters

cipher_algo

The cipher method, see openssl_get_cipher_methods() for a list of potential values.

Return Values

Returns the cipher length on success, Falseforfailure.

Errors/Exceptions

Emits an E_WARNING level error when the cipher algorithm is unknown.

Examples

openssl_cipher_key_length() example

php
<?php
$method = 'AES-128-CBC';

var_dump(openssl_cipher_key_length($method));
?>

The above example will output something similar to:

output
int(16)

Source: reference/openssl/functions/openssl-cipher-key-length.xml · from the official PHP manual (php/doc-en)