public function generate($random = null) {
		$results = [];

		$plaintext = $this->_convert($random ?: $this->_random(8));
		// String is already normalized by used alphabet.

		$part = $try = 0;
		while (count($results) < $this->_parts) {
			$result = substr($plaintext, $try * $this->_partLength, $this->_partLength - 1);

			if (!$result || strlen($result) !== $this->_partLength - 1) {
				throw new Exception('Ran out of plaintext.');
			}
			$result .= $this->_checkdigitAlg1($part + 1, $result);

			$try++;
			if ($this->_isBadWord($result) || $this->_isValidWhenSwapped($result)) {
				continue;
			}
			$part++;

			$results[] = $result;
		}
		return implode('-', $results);
	}