private function getProcessedReversedMapping($mapping) { $output = $mapping; for ($i = 0; $i < count($mapping); $i++) { $output[toInt($mapping[$i])] = toChar($i); } return $output; }
function randomCodeGenerator($length) { $code = ""; for ($i = 0; $i < $length; $i++) { //generate a random number between 1 and 35 $r = mt_rand(1, 35); //if the number is greater than 26, minus 26 will generate a digit between 0 and 9 if ($r > 26) { $r = $r - 26; $code = $code . $r; } else { //it's between 1 and 26, generate a character $code = $code . toChar($r); } } return $code; }
public function convert($char) { $position = toInt($char); return isset($this->plugs[$position]) ? toChar($this->plugs[$position]) : $char; }