Skip to content

Instantly share code, notes, and snippets.

@eAmin
Last active December 17, 2015 23:39
Show Gist options
  • Select an option

  • Save eAmin/5691323 to your computer and use it in GitHub Desktop.

Select an option

Save eAmin/5691323 to your computer and use it in GitHub Desktop.
Generate random bytes from /dev/urandom/
function gen_random_pass($length=20) {
return (function_exists('openssl_random_pseudo_bytes')) ?
base64_encode(openssl_random_pseudo_bytes($length))
: base64_encode(mcrypt_create_iv($length, MCRYPT_DEV_URANDOM));
}
$generate = gen_random_pass();
echo 'Generated password: '.$generate;
file_put_contents('pass.txt', $generate."\r\n\r\n", FILE_APPEND);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment