by Anish
Posted on Wednesday December 12 , 2018
In cryptography, PBKDF1 and PBKDF2 (Password-Based Key Derivation Function 2) are key derivation functions with a sliding computational cost, aimed to reduce the vulnerability of encrypted keys to brute force attacks.
The PBKDF2 key derivation function has five input parameters:
DK = PBKDF2(PRF, Password, Salt, c, dkLen)
where:
php openssl function openssl_pbkdf2: Generates a PKCS5 v2 PBKDF2 string, defaults to SHA-1
The Syntax
string openssl_pbkdf2 ( string $password , string $salt , int $key_length , int $iterations [, string $digest_algorithm ] )
Best Practice for PBKDF2 :
Examples
openssl_pbkdf2() example Deriving key for my given password
<?php
/**
* Created by https://8gwifi.org
* User: Anish Nath
* Date: 2018-12-17 * Time: 14:44 */
echo "Deriving password for my Given Password\n";
echo "PBKDF2 Example of using SHA algorithms, with random salt value of 16 and the output keylength of 32\n";
$password= "myverystrongpassword";
$salt=openssl_cipher_iv_length(16);
$key_length =32;
$iterations=10000;
$dk = openssl_pbkdf2($password,salt,$key_length,$iterations,"SHA");
echo base64_encode($dk);
The above example will output something similar to:
$ /usr/bin/php pbkdf2.php
Deriving password for my Given Password
UhkRrY90Uu7JYNtBXZJszLr4vZ0NaAvBCRDhoNLPcZA=
Continue Reading how to generate ec key pair
Thanku for reading !!! Give a Share for Support
Asking for donation sound bad to me, so i'm raising fund from by offering all my Nine book for just $9