I am using codeigniter 3
And i am trying to build stay signing functionality
In hash_hmac() i am passing an array , but i want to convert it into a string ,
Can any one tell me how to convert it?
/*
| ---------------------------------------------------------------------------
| REMEMBER ME TOKEN
| ---------------------------------------------------------------------------
| When a user logs in and selects the remember me option then you will generate a key using PHP's hash_hmac function.
| The data will be the IP address, browser name, username and password and the key (hash_hmac's 3rd parameter)
| will be a random string of any length you desire.
| The algorithm can be bcrypt/SHA512/crypt/etc.. This should give you a key of 128 characters in length.
| Store this key within the table RememberMe.
| Table contains user ID, 128 char long key ,expiry date of the key.
*/
if($remember_me == TRUE){
$this->load->library('user_agent');
$user_agent = $this->agent->browser();
$user_agent_version = $this->agent->version();
$ip = $this->input->ip_address();
$rand128_hex = bin2hex(openssl_random_pseudo_bytes(16));
$data = array(
'ip' => $ip,
'user_agent' => $user_agent,
'email' => $email,
'password' => $password
);
echo hash_hmac('crypt', $data, $rand128_hex);
}
chaitu11 0 Junior Poster
diafol
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.