Skip to content

Instantly share code, notes, and snippets.

@lcherone
Last active August 29, 2015 14:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lcherone/6b0e04d6bc6eb8306f20 to your computer and use it in GitHub Desktop.
Save lcherone/6b0e04d6bc6eb8306f20 to your computer and use it in GitHub Desktop.
Random A1phaNumEr1c infinite length string function
<?php
echo passgen(20); //K4YFnMW5muf0kZTMl6h3
function passgen($length = 20)
{
// define base string - add multiplex to pad to an infinate length
$alpha = str_repeat(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
intval($length + 1)
);
$numeric = str_repeat(
"0123456789",
intval($length + 1)
);
//shuffle the base string and set first character as an alpha
return substr(str_shuffle($alpha), 0, 1)
. substr(str_shuffle($alpha.$numeric), 0, intval($length - 1));
}
?>
@lcherone
Copy link
Author

lcherone commented Dec 3, 2014

Added multiplex onto numbers to increase the number entropy in resulting hash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment