Hashing Passwords with PHP Coding

Sangwan Pankaj Reply 02:50
With the last version of PHP, there are many actual methods included in the core language that you should use in your code files. These will help you a lot that you might have working out the easist way to creat a salt. So, if you are able to do, I suggest you to switch to using this method everywhere (if possible) you generate passwords.

Hashing Logic is as simple as you doing this:

password_hash('YouRSuperSecure&(*$p880$0w0rd!', PASSWORD_BCRYPT);

Here, you pass in the string that you want to hash, and the method of hashing that you’re looking to use. You can add the second parameter, and stick to the default that PHP chooses to the best.

By default the method will use a cost of 10, which is a good level to start at, however if you want to change this, you can pass through the cost as a third parameter as an array of options.

See below example sets the cost value to 16 (min is 4, max is 30)

Example:- 

password_hash('YouRSuperSecure&(*$p880$0w0rd!', PASSWORD_BCRYPT, ['cost' => 16]);


It’s just that easy like anything! Enjoy!. 

Please do share our blog with interested coders and those you always ready to learn. 

How to Insert data into table from excel file in php

Sangwan Pankaj Reply 00:29

How to Insert data into table from excel file in php


Step 1:- Open an excel file and save as "Excel Data" text file and in below sample code, "test.txt" is excel-data excel file.

Step 2:- Now, follow the below instruction for create code for insert data into table in mysql using php.


<?php
  include 'config.php';
// Connect to your database.

$fp = fopen("test.txt", "r");    // Open that file('Excel Data') for reading

while($line = fgets($fp))      // Loop through each line
{

     list ($name, $first) = explode("\t", $line);

     // Split the line by the Excel Data and store it in our list...

     $sql = "insert into user (name,phone) values ('$name', '$first')";

     // Generate sql string...

     mysql_query($sql) or die ( mysql_error() );        // Execute the sql

}

?>

Step 3:- Run file.
Copyright by GhostPHP. Powered by Blogger.

Search

Recent Post

Popular Posts

Follow us