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:----R5japi+h5A9xtJ5uQ+YwV0YLWwNOFycXnaTfMNkLPKDr+LCPga9gfW7MTjOKgD13ER/wspGWnUb5weFouaj68f3H3VLm0qM4r8Dfye2889dnTNebt+iHn+SKJSygipcl9MEsE3RsOPIErmz7G3ZGjz8vm1w5SsG3he1pgSFkbIbO9xpNZUPJaNFdozTOpRtRq2NEcPDwV7qf4ZyLcZ73KQSOvAwundgGbr4/NeDE0E88mKwjv55pnnwVgCQH3vhLNx8m4/pk/KU1lFriVSpABmg9WZoWbmOh/JAN2n9yLyv3ZGOdMWU80bwcY7IcEZdTg9Yl6NgNNjHdsmasyR52Q/cxtIbPduKhQ2jSssK6P9sPhBIEWrq5tbKb0FL69nkPVg0/xhOSEL1a1Vf2OyIETg3BnEYYaoAPxP270yVcx1/gPKHz232XSNnYNE8hyO88L0FrCZsfGA0ymlzQTYbOP3u5rzHoTOoIShTpst6NhTlMpvBAC8YwoJKU5FjF0Xh1nPS2xN8xe2bIGDFHSSUmULsN3jBYWY/3O3ZUK8755RBLwKh28ML2yVrfBXLtiuYzp6VbaaYk3hh5ZSDM7zK2V5+tPhf9GgcANt2asIEHZBBMQ5YjrrPteCg73uglrEJV2elWl4k6fn2pfKrzdSMiWSmFZu4te+cx4vzcNBc87KE=----ATTACHMENT:----MzMzMzkwMTczMjcxNzI5OCA3MzQ0NDI4MDY3ODQ5NTI2IDI5ODAwNjg0NDQ5MjA0ODQ=