/** ** * GetRandomPassPhrase returns a prounoucable password of the given length * filtering out potential offensive words ** @public ** @param int $$pass_length ** @return string $password. **/ static function GetRandomPassPhrase($length = 8) { srand((double) microtime() * 1000000); $vowels = array("a", "e", "i", "o", "u"); $cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr", "cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl"); $badwords = array("fuc", "shit", "ass", "pus", "s**t", "dic", "f*g", "coc", "cun", "cum", "dam", "nig", "kik", "spic", "neg", "bitc", "gay", "poo", "twa", "vag", "peni", "whor"); $num_vowels = count($vowels); $num_cons = count($cons); $password = ""; for ($i = 0; $i < $length; $i++) { $password .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)]; } $newpass = substr($password, 0, $length); // ensure this is not a potentially offensive password foreach ($badwords as $badword) { if (strpos($newpass, $badword) !== false) { return PassPhrase::GetRandomPassPhrase($length); } } return $newpass; }
/** * @return string */ public function getSubString() { return substr($this->passPhrase->getSuperKey(), $this->getRandomDecimalPosition(), $this->parameterLength); }