函式名:mcrypt_module_get_supported_key_sizes()
適用版本:PHP 4 >= 4.0.2, PHP 5, PHP 7
用法:
mcrypt_module_get_supported_key_sizes ( string $algorithm [, string $lib_dir ] ) : array
該函式用於獲取指定演算法支援的金鑰長度。
引數:
- algorithm: 字串型別,表示加密演算法的名稱,比如 "des", "tripledes", "blowfish" 等。
- lib_dir(可選): 字串型別,表示自定義的庫目錄,用於指定mcrypt庫的位置。
返回值:
- 返回一個包含支援的金鑰長度的陣列。
示例:
$algorithm = "blowfish";
$supported_key_sizes = mcrypt_module_get_supported_key_sizes($algorithm);
echo "Supported key sizes for $algorithm algorithm: " . implode(", ", $supported_key_sizes);
輸出:
Supported key sizes for blowfish algorithm: 8, 16, 24, 32
在上面的示例中,我們使用了"blowfish"演算法作為引數呼叫了mcrypt_module_get_supported_key_sizes()函式。該函式返回一個包含支援的金鑰長度的陣列。我們使用implode()函式將陣列中的元素以逗號分隔的形式輸出到螢幕上。結果顯示了"blowfish"演算法支援的金鑰長度為8、16、24和32。