Skip to content

Instantly share code, notes, and snippets.

@badcrc
badcrc / passwd.php
Last active December 17, 2015 21:49
Generate random password in php
<?php
function generate_pass($length) {
$chars = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPRQSTUVWXYZ_-";
$code = "";
while (strlen($code) < $length) {
$code .= $chars[mt_rand(0,strlen($chars))];
}
return $code;