public static function encrypt(
        $input,
        $output,
        EncryptionKey $key
    ): int {
        if (
            (\is_resource($input) || \is_string($input) || ($input instanceof ReadOnlyFile))
                &&
            (\is_resource($output) || \is_string($output) || ($output instanceof MutableFile))
        ) {
            try {
                if ($input instanceof ReadOnlyFile) {
                    $readOnly = $input;
                } else {
                    $readOnly = new ReadOnlyFile($input);
                }
                if ($output instanceof MutableFile) {
                    $mutable = $output;
                } else {
                    $mutable = new MutableFile($output);
                }
                $data = self::encryptData(
                    $readOnly,
                    $mutable,
                    $key
                );
                return $data;
            } finally {
                if (isset($readOnly)) {
                    $readOnly->close();
                }
                if (isset($mutable)) {
                    $mutable->close();
                }
            }
        }
        throw new InvalidType(
            'Argument 1: Expected a filename or resource'
        );
    }