$custom = PasswordGenerator::getCustomPassword(array('a', 'b'), 64); echo $ascii, "\n", $hex, "\n", $alpha, "\n", $custom, "\n\n"; function failTest($msg) { echo "FAILED: {$msg}\n"; exit(1); } $last = array(); $ascii_chars = array(); $alpha_chars = array(); $hex_chars = array(); $custom_chars = array(); for ($i = 0; $i < 20; $i++) { $ascii = PasswordGenerator::getASCIIPassword(64); $alpha = PasswordGenerator::getAlphaNumericPassword(64); $hex = PasswordGenerator::getHexPassword(64); $custom = PasswordGenerator::getCustomPassword(array('a', 'b'), 64); if (in_array($ascii, $last)) { failTest("Duplicate ASCII password."); } if (in_array($alpha, $last)) { failTest("Duplicate AlphaNumeric password."); } if (in_array($hex, $last)) { failTest("Duplicate Hex password."); } if (in_array($custom, $last)) { failTest("Duplicate Custom password."); } if (preg_match("/^[!-~]{64}\$/", $ascii) !== 1) { failTest("ASCII regexp failed.");