encrypt($plainText); return self::PREFIX . base64_encode($encrypted); } public function decrypt(string $cipherText): string { if ($cipherText === '') { return $cipherText; } if (! str_starts_with($cipherText, self::PREFIX)) { return $cipherText; } try { $payload = base64_decode(substr($cipherText, strlen(self::PREFIX)), true); if ($payload === false) { return ''; } return (string) service('encrypter')->decrypt($payload); } catch (Throwable) { return ''; } } }