Пример #1
0
bool XorEncryptor::encryptData(std::fstream &original, std::fstream &result)
{
	if (!original.is_open() || !result.is_open())
	{
		return false;
	}

	original.seekg(0, std::ios::beg);
	result.seekp(0, std::ios::beg);

	char c = 0;
	unsigned i = 0;
	while (original.good())
	{
		original.read(&c, 1);
		c ^= password[i];
		if(original.gcount() > 0)
		{
			result.write(&c, 1);
		}

		if (++i == passSize)
		{
			i = 0;
		}
	}

	original.seekg(0, std::ios::beg);
	result.seekg(0, std::ios::beg);
	result.flush();

	return true;
}
void Agente::leerLinea(std::fstream& archivo, std::string& linea) {
	linea.clear();

	char buffer[T_BUFFER];

	bool seguirLeyendo = true;
	do {
		archivo.getline(buffer, T_BUFFER, '\n');
		linea.append(buffer, archivo.gcount());

		seguirLeyendo = (archivo.gcount() == T_BUFFER);

		if (archivo.bad())
			archivo.clear();

	} while (seguirLeyendo);
}
Пример #3
0
bool
StandardFileProvider::read( void* buffer, Size size, Size& nin, Size maxChunkSize )
{
    _fstream.read( (char*)buffer, size );
    if( _fstream.fail() )
        return true;
    nin = _fstream.gcount();
    return false;
}
Пример #4
0
	/**
	 * Read data from the stream. Subclasses must implement this
	 * method; all other read methods are implemented using it.
	 *
	 * @note The semantics of any implementation of this method are
	 * supposed to match those of ISO C fread(), in particular where
	 * it concerns setting error and end of file/stream flags.
	 *
	 * @param dataPtr	pointer to a buffer into which the data is read
	 * @param dataSize	number of bytes to be read
	 * @return the number of bytes which were actually read.
	 */
	virtual uint32 read(void *dataPtr, uint32 dataSize) {
		_stream->read((char*)dataPtr, dataSize);
		return _stream->gcount();
	}