Skip to content

Instantly share code, notes, and snippets.

View darmentrout's full-sized avatar
💭
I've got fun Gists, too.

Damion Armentrout darmentrout

💭
I've got fun Gists, too.
View GitHub Profile
@darmentrout
darmentrout / generatePassword.php
Last active June 27, 2018 14:05 — forked from zyphlar/generatePassword.php
Generating secure passwords in PHP
<?php
// usage: $newpassword = generatePassword(12); // for a 12-char password, upper/lower/numbers.
// functions that use rand() or mt_rand() are not secure according to the PHP manual.
function getRandomBytes( $nbBytes = 32 ){
$bytes = openssl_random_pseudo_bytes( $nbBytes, $strong );
if ( false !== $bytes && true === $strong ) {
return $bytes;
}