encrypt($plaintext); } /** * Decrypt the cipher text. * * @param string $cipherText Cipher text * * @return bool|string Plaintext * `false` if unable to decrypt * * @throws Exception */ public function decrypt($cipherText) { return self::$engine->decrypt($cipherText); } /** * @param string $header * @param string $bytes * * @return string * * @throws EnvironmentIsBrokenException */ public static function saveBytesToChecksummedAsciiSafeString($header, $bytes) { $engine = self::resolveEngineToUse(); return $engine::saveBytesToChecksummedAsciiSafeString($header, $bytes); } /** * @return string * * @throws Exception */ public static function createNewRandomKey() { $engine = self::resolveEngineToUse(); try { $randomKey = $engine::createNewRandomKey(); } catch (EnvironmentIsBrokenException $exception) { $buf = $engine::randomCompat(); $randomKey = $engine::saveToAsciiSafeString($buf); } return $randomKey; } /** * Choose which engine use regarding the OpenSSL cipher methods available. */ public static function resolveEngineToUse() { return self::ENGINE; } }