Skip to content

Instantly share code, notes, and snippets.

@badcrc
Last active December 17, 2015 21:49
Show Gist options
  • Save badcrc/5677201 to your computer and use it in GitHub Desktop.
Save badcrc/5677201 to your computer and use it in GitHub Desktop.
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;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment