note 112817 added to function.crypt

From: Date: Fri, 26 Jul 2013 08:16:16 +0000
Subject: note 112817 added to function.crypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-195776@lists.php.net to get a copy of this message
<?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> ---- Server IP: 69.147.83.199 Probable Submitter: 98.176.50.73 ---- Manual Page -- http://php.net/manual/en/function.crypt.php Edit -- https://master.php.net/note/edit/112817 Del: integrated -- https://master.php.net/note/delete/112817/integrated Del: useless -- https://master.php.net/note/delete/112817/useless Del: bad code -- https://master.php.net/note/delete/112817/bad+code Del: spam -- https://master.php.net/note/delete/112817/spam Del: non-english -- https://master.php.net/note/delete/112817/non-english Del: in docs -- https://master.php.net/note/delete/112817/in+docs Del: other reasons-- https://master.php.net/note/delete/112817 Reject -- https://master.php.net/note/reject/112817 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195776) next »