note 112817 deleted from function.crypt by cmb

From: Date: Mon, 07 Sep 2015 11:46:35 +0000
Subject: note 112817 deleted from function.crypt by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-203725@lists.php.net to get a copy of this message
Note Submitter: mrdaniel619 at gmail dot com ---- <?php /* nice script for creating a hash with random salt */ function rand_str($length, $charset='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') { $str = ''; $count = strlen($charset); while ($length--) { $str .= $charset[mt_rand(0, $count-1)]; } return $str; } $hash = ""; if(isset($_POST['string']) && !empty($_POST['string']) && is_string($_POST['string'])) { $salt = rand_str(rand(100,200)); $hash = crypt($_POST['string'], '$6$rounds=9000$'.$salt.'$'); } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <body> <h1>512 Hash</h1> <div><?= $hash ?></div> <form method ="post"> <table> <tr> <td> <input type ="text" value ="<?php if($hash!== ""){ echo htmlspecialchars($_POST['string']); } ?>" id ="string" name ="string" /> </td> <td> <input type ="submit" value ="hash" /> </td> </tr> </table> </form> </body> </html>

« previous php.notes (#203725) next »