salt, $this->length); return $hi->encode($id); } public function getID($hash) { $hi = new Hashids($this->salt, $this->length); $id_array = $hi->decode($hash); // return null if unable to decode aka invalid hash if (empty($id_array)) return null; // first one should be the id return $id_array[0]; } }