openssl_get_cipher_methods 获取可用的加密算法
发表日期:2021-07-01 08:55:21 | 来源: | | 浏览(1434) 分类:OpenSSL 函数
openssl_get_cipher_methods
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
openssl_get_cipher_methods — 获取可用的加密算法
说明
openssl_get_cipher_methods(bool
$aliases = false): array获取可用的加密算法的列表。
参数
-
aliases -
如果密码别名应该包含在返回的array中,则设置为
true.
返回值
包含可用加密算法的array。 请注意:在 OpenSSL 1.1.1 版本之前,返回加密算法的拼法大小写都有; 从 OpenSSL 1.1.1 开始,统一只返回小写的形式。
范例
示例 #1 openssl_get_cipher_methods() example
展示了哪些加密算法能被找到,哪些别名可用。
<?php
$ciphers = openssl_get_cipher_methods();
$ciphers_and_aliases = openssl_get_cipher_methods(true);
$cipher_aliases = array_diff($ciphers_and_aliases, $ciphers);
//ECB mode should be avoided$ciphers = array_filter( $ciphers, function($n) {
return stripos($n,"ecb")===FALSE;
}
);
//At least as early as Aug 2016, Openssl declared the following weak: RC2, RC4, DES, 3DES, MD5 based$ciphers = array_filter( $ciphers, function($c) {
return stripos($c,"des")===FALSE;
}
);
$ciphers = array_filter( $ciphers, function($c) {
return stripos($c,"rc2")===FALSE;
}
);
$ciphers = array_filter( $ciphers, function($c) {
return stripos($c,"rc4")===FALSE;
}
);
$ciphers = array_filter( $ciphers, function($c) {
return stripos($c,"md5")===FALSE;
}
);
$cipher_aliases = array_filter($cipher_aliases,function($c) {
return stripos($c,"des")===FALSE;
}
);
$cipher_aliases = array_filter($cipher_aliases,function($c) {
return stripos($c,"rc2")===FALSE;
}
);
print_r($ciphers);
print_r($cipher_aliases);
?>
以上例程的输出类似于:
Array
(
[0] => aes-128-cbc
[1] => aes-128-cbc-hmac-sha1
[2] => aes-128-cbc-hmac-sha256
[3] => aes-128-ccm
[4] => aes-128-cfb
[5] => aes-128-cfb1
[6] => aes-128-cfb8
[7] => aes-128-ctr
[9] => aes-128-gcm
[10] => aes-128-ocb
[11] => aes-128-ofb
[12] => aes-128-xts
[13] => aes-192-cbc
[14] => aes-192-ccm
[15] => aes-192-cfb
[16] => aes-192-cfb1
[17] => aes-192-cfb8
[18] => aes-192-ctr
[20] => aes-192-gcm
[21] => aes-192-ocb
[22] => aes-192-ofb
[23] => aes-256-cbc
[24] => aes-256-cbc-hmac-sha1
[25] => aes-256-cbc-hmac-sha256
[26] => aes-256-ccm
[27] => aes-256-cfb
[28] => aes-256-cfb1
[29] => aes-256-cfb8
[30] => aes-256-ctr
[32] => aes-256-gcm
[33] => aes-256-ocb
[34] => aes-256-ofb
[35] => aes-256-xts
[36] => aria-128-cbc
[37] => aria-128-ccm
[38] => aria-128-cfb
[39] => aria-128-cfb1
[40] => aria-128-cfb8
[41] => aria-128-ctr
[43] => aria-128-gcm
[44] => aria-128-ofb
[45] => aria-192-cbc
[46] => aria-192-ccm
[47] => aria-192-cfb
[48] => aria-192-cfb1
[49] => aria-192-cfb8
[50] => aria-192-ctr
[52] => aria-192-gcm
[53] => aria-192-ofb
[54] => aria-256-cbc
[55] => aria-256-ccm
[56] => aria-256-cfb
[57] => aria-256-cfb1
[58] => aria-256-cfb8
[59] => aria-256-ctr
[61] => aria-256-gcm
[62] => aria-256-ofb
[63] => bf-cbc
[64] => bf-cfb
[66] => bf-ofb
[67] => camellia-128-cbc
[68] => camellia-128-cfb
[69] => camellia-128-cfb1
[70] => camellia-128-cfb8
[71] => camellia-128-ctr
[73] => camellia-128-ofb
[74] => camellia-192-cbc
[75] => camellia-192-cfb
[76] => camellia-192-cfb1
[77] => camellia-192-cfb8
[78] => camellia-192-ctr
[80] => camellia-192-ofb
[81] => camellia-256-cbc
[82] => camellia-256-cfb
[83] => camellia-256-cfb1
[84] => camellia-256-cfb8
[85] => camellia-256-ctr
[87] => camellia-256-ofb
[88] => cast5-cbc
[89] => cast5-cfb
[91] => cast5-ofb
[92] => chacha20
[93] => chacha20-poly1305
[111] => id-aes128-CCM
[112] => id-aes128-GCM
[113] => id-aes128-wrap
[114] => id-aes128-wrap-pad
[115] => id-aes192-CCM
[116] => id-aes192-GCM
[117] => id-aes192-wrap
[118] => id-aes192-wrap-pad
[119] => id-aes256-CCM
[120] => id-aes256-GCM
[121] => id-aes256-wrap
[122] => id-aes256-wrap-pad
[124] => idea-cbc
[125] => idea-cfb
[127] => idea-ofb
[137] => seed-cbc
[138] => seed-cfb
[140] => seed-ofb
[141] => sm4-cbc
[142] => sm4-cfb
[143] => sm4-ctr
[145] => sm4-ofb
)
Array
(
[36] => aes128
[37] => aes128-wrap
[38] => aes192
[39] => aes192-wrap
[40] => aes256
[41] => aes256-wrap
[69] => aria128
[70] => aria192
[71] => aria256
[72] => bf
[77] => blowfish
[99] => camellia128
[100] => camellia192
[101] => camellia256
[102] => cast
[103] => cast-cbc
[146] => idea
[164] => seed
[169] => sm4
)
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- openssl_cipher_iv_length 获取密码iv长度(0)
- openssl_cms_decrypt Decrypt a CMS message(0)
- openssl_cms_encrypt Encrypt a CMS message(0)
- openssl_cms_read Export the CMS file to an array of PEM certificates(0)
- openssl_cms_sign Sign a file(0)
- openssl_cms_verify Verify a CMS signature(0)
- openssl_csr_export_to_file 将CSR导出到文件(0)
- openssl_csr_export 将CSR作为字符串导出(0)
- openssl_csr_get_public_key 返回CSR的公钥(0)
- openssl_csr_get_subject 返回CSR的主题(0)
- openssl_csr_new 生成一个 CSR(0)
- openssl_csr_sign 用另一个证书签署 CSR (或者本身) 并且生成一个证书(0)
- openssl_decrypt 解密数据(0)
- openssl_dh_compute_key 计算远程DH密钥(公钥)和本地DH密钥的共享密钥(0)
- openssl_digest 计算摘要(0)
- openssl_encrypt 加密数据(0)
- openssl_error_string 返回 openSSL 错误消息(0)
- openssl_free_key 释放密钥资源(0)
- openssl_get_cert_locations 检索可用的证书位置(0)
- openssl_get_cipher_methods 获取可用的加密算法(0)
- openssl_get_curve_names 获得ECC的可用曲线名称列表(0)
- openssl_get_md_methods 获取可用的摘要算法(0)
- openssl_get_privatekey 别名 openssl_pkey_get_private()(0)
- openssl_get_publickey 别名 openssl_pkey_get_public()(0)
- openssl_open 打开密封的数据(0)
- openssl_pbkdf2 生成一个 PKCS5 v2 PBKDF2 字符串(0)
- openssl_pkcs12_export_to_file 输出一个 PKCS#12 兼容的证书存储文件(0)
- openssl_pkcs12_export 将 PKCS#12 兼容证书存储文件导出到变量(0)
- openssl_pkcs12_read 将 PKCS#12 证书存储区解析到数组中(0)
- openssl_pkcs7_decrypt 解密一个 S/MIME 加密的消息(0)
- openssl_pkcs7_encrypt 加密一个 S/MIME 消息(0)
- openssl_pkcs7_read 将 PKCS7 文件导出为 PEM 格式证书的数组(0)
- openssl_pkcs7_sign 对一个 S/MIME 消息进行签名(0)
- openssl_pkcs7_verify 校验一个已签名的 S/MIME 消息的签名(0)
- openssl_pkey_derive Computes shared secret for public value of remote and local DH or ECDH key(0)
- openssl_pkey_export_to_file 将密钥导出到文件中(0)
- openssl_pkey_export 将一个密钥的可输出表示转换为字符串(0)
- openssl_pkey_free 释放一个私钥(0)
- openssl_pkey_get_details 返回包含密钥详情的数组(0)
- openssl_pkey_get_private 获取私钥(0)
- openssl_pkey_get_public 从证书中解析公钥,以供使用。(0)
- openssl_pkey_new 生成一个新的私钥(0)
- openssl_private_decrypt 使用私钥解密数据(0)
- openssl_private_encrypt 使用私钥加密数据(0)
- openssl_public_decrypt 使用公钥解密数据(0)
- openssl_public_encrypt 使用公钥加密数据(0)
- openssl_random_pseudo_bytes 生成一个伪随机字节串(0)
- openssl_seal 密封 (加密) 数据(0)
- openssl_sign Generate signature(0)
- openssl_spki_export_challenge 导出与签名公钥和挑战相关的挑战字符串(0)
- openssl_spki_export 通过签名公钥和挑战导出一个可用的PEM格式的公钥(0)
- openssl_spki_new 生成一个新的签名公钥和挑战(0)
- openssl_spki_verify 验证签名公钥和挑战。(0)
- openssl_verify 验证签名(0)
- openssl_x509_check_private_key 检查私钥是否对应于证书(0)
- openssl_x509_checkpurpose 验证是否可以为特定目的使用证书(0)
- openssl_x509_export_to_file 导出证书至文件(0)
- openssl_x509_export 以字符串格式导出证书(0)
- openssl_x509_fingerprint 计算一个给定的x.509证书的指纹或摘要(0)
- openssl_x509_free 释放证书资源(0)
- openssl_x509_parse 解析一个X509证书并作为一个数组返回信息(0)
- openssl_x509_read 解析一个x.509证书并返回一个资源标识符(0)
- openssl_x509_verify Verifies digital signature of x509 certificate against a public key(0)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)
宁公网安备 64010402001209号