/ Published in: PHP

This simple snipplr will convert an password string to an censored string by stars (*). Usage:\r\n$myPwdCensored=passToStars(\\"password\\");\r\necho $myPwdCensored;\r\nI made this in 5min Comment and FAV ! :-)\r\nMore PHP \"Snipplr\"s coming soon !
Expand |
Embed | Plain Text
<?php function passToStars($password) { //Convert an password into stars (*) with PHP //© ofadlaoui @ Snipplr.com $number = 0; $stars = ""; //empty string while ($number != $password) //While an number isn't the lenght of the password.. { $stars += "*"; //.. PHP will add an star to the empty string. $number++; //If we don't excecute this, the page $stars will be unlimited. } return $stars; } // Usage: $myPwdCensored=passToStars("password"); echo $myPwdCensored; ?>
Comments

You need to login to post a comment.
function passToStars($password) { return str_repeat('*', strlen($password)); }
@Sverri Lol thanks, but you can submit an new snipplr, because now you're ruin my snippet..
sorry for saying this but this is kinda stupid because you are turning on the guesses never ever do that on a production website.
if you want to censor pass just put **** stars not the lenght of the pass
needs to have line 10 changed to:
$stars .= "*"; //.. PHP will add an star to the empty string.