/** * Get a substitution table entry * * @param int $pos * @return string */ public function getSubstitutionTableEntry($pos) { $str = $this->plaintext_key; if ($pos != 0) { $str = Helper::rotate($str, $pos); } return $str; }
/** * Make a run of rotation * * @param null $rotation * @return $this */ public function rotate($rotation = null) { if (is_null($rotation)) { $rotation = $this->rotation; } $cipher = $this->getSubstitutions(); $this->setSubstitutions(array(Helper::rotate($cipher[0], $rotation))); return $this; }
/** * Reset the substitution table to its original form * * @return $this */ protected function _reset() { parent::_reset(); $this->substitution_table->setSubstitutions(array(str_split(Helper::rotate($this->substitution_table->getPlaintextKey(), $this->rotation_value - 1)))); return $this; }