Last active
December 17, 2015 23:39
-
-
Save eAmin/5691323 to your computer and use it in GitHub Desktop.
Generate random bytes from /dev/urandom/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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