(PHP 5 >= 5.5.0, PHP 7)
openssl_pbkdf2 — ����һ�� PKCS5 v2 PBKDF2 �ַ���
$password
, string $salt
, int $key_length
, int $iterations
[, string $digest_algorithm
= "sha1"
] ) : stringopenssl_pbkdf2() ���� PBKDF2 (Password-Based Key Derivation Function 2), ��PKCS5 v2�ж����һ����Կ���Ƶ�����.
password
������Կ�����ɵ����롣
salt
PBKDF2 �Ƽ�һ��������64λ(8�ֽ�)��������ֵ��
key_length
ϣ�������Կ�ij��ȡ�
iterations
��Ҫ�ĵ������� » NIST ��������10,000��.
digest_algorithm
��openssl_get_md_methods()�п�ѡ��ɢ�л�ժҪ�㷨.Ĭ���� SHA-1.
�ɹ�������ԭʼ�������ַ��� ������ʧ��ʱ���� FALSE
.
Example #1 openssl_pbkdf2() ����
<?php
$password = 'yOuR-pAs5w0rd-hERe';
$salt = openssl_random_pseudo_bytes(12);
$keyLength = 40;
$iterations = 10000;
$generated_key = openssl_pbkdf2($password, $salt, $keyLength, $iterations, 'sha256');
echo bin2hex($generated_key)."\n";
echo base64_encode($generated_key)."\n";
?>