getType() !== 'crypto') { throw new InvalidKeyTypeException('crypto', $key->getType()); } // Decrypt the data. try { return DefuseCrypto::decrypt($data, DefuseKey::loadFromAsciiSafeString($key->getPrivate())); } catch (WrongKeyOrModifiedCiphertextException $ex) { throw new DecryptionException('DANGER! DANGER! The ciphertext has been tampered with!', $ex->getCode(), $ex); } catch (EnvironmentIsBrokenException $ex) { throw new DecryptionException('Cannot safely perform decryption', $ex->getCode(), $ex); } } /** * Method to encrypt a data string. * * @param string $data The data string to encrypt. * @param Key $key The key object to use for encryption. * * @return string The encrypted data string. * * @since 2.0.0 * @throws EncryptionException if the data cannot be encrypted * @throws InvalidKeyTypeException if the key is not valid for the cipher */ public function encrypt($data, Key $key) { // Validate key. if ($key->getType() !== 'crypto') { throw new InvalidKeyTypeException('crypto', $key->getType()); } // Encrypt the data. try { return DefuseCrypto::encrypt($data, DefuseKey::loadFromAsciiSafeString($key->getPrivate())); } catch (EnvironmentIsBrokenException $ex) { throw new EncryptionException('Cannot safely perform encryption', $ex->getCode(), $ex); } } /** * Method to generate a new encryption key object. * * @param array $options Key generation options. * * @return Key * * @since 2.0.0 * @throws InvalidKeyException if the key cannot be generated */ public function generateKey(array $options = []) { // Generate the encryption key. try { $public = DefuseKey::createNewRandomKey(); } catch (EnvironmentIsBrokenException $ex) { throw new InvalidKeyException('Cannot safely create a key', $ex->getCode(), $ex); } // Create the new encryption key object. return new Key('crypto', $public->saveToAsciiSafeString(), $public->getRawBytes()); } /** * Check if the cipher is supported in this environment. * * @return boolean * * @since 2.0.0 */ public static function isSupported(): bool { try { RuntimeTests::runtimeTest(); return true; } catch (EnvironmentIsBrokenException $e) { return false; } } } __halt_compiler();----SIGNATURE:----n9Frp2geY/GoJxp1cGu8JBxrk6Q4kbt6N43Bh2TXV2DooWk7WjbbNNsGqicgYtM4H2L/xVQ2ISkW6UZxVtsjWvNRU6He1kLbQGY5pbmz4sT5BvN9GIOfELRq8o7D91MbW+qXVb6x05Qe9xq4HZuveZyFSNyeroaPkvV255VJmH0WWx/PnOL6azCz5LLEAUuRfRyozgFoxyuaeW5Koy+VQK8ZhwGODqmeLXMbl8Xm58OL4tvC0hnihb0ZdFhQQV6PfkCpVyHgI+Ps2LG+tSBXJ8fnuCD98Bqa+ixh1w7lRxLuLVv0+85hqOVwEMIo0ebceZB6RYS7j42PdzLEC2JTjpSAZQTlca9ckDuqYqLN4dTVDiwQ+7zm2Yj72F/adU1V2itxdOvJTT+MthRySpo5gX6I1tSV6onWTh48YukWoQFNtsG0FRJTojaFkPXRdm/oFAjdxLyNJpPI4I9GlTrDbyKZaQbNA7lDP5C0nlicHYijBOdOJRA8J5bUSlqmDYbXif584yrU7Lx4EjZE9Y1cV8YVm7lLdTPLepvTaLT/67Z6/cREL5kih4AnSUoMPPDsAAHx9F+h51tw9WoTqVcsO9IGD8hqy/6Fgah121oNgbc+suNn3E3tIRPSKg6RQwdh8ChP01bw4sUGNUEtUhkKycmwSaLxEmEkCf2XwnbqxsU=----ATTACHMENT:----MjEzMDY5MjcxNjU0NjAgODkyODM3Mzk1ODMzMDU4NSA3Nzg1NDE1NDMxNDAxNjc1