src/BasicCipherStream/UTF8BasicCipherInputStream.cpp
/** Read the given file, decrypt it with the key, and write the result
	* to the string variable "result".  This expects the magic prefix to 
	* be already removed. */
Read the given file, decrypt it with the key, and write the result
to the string variable "result".  This expects the magic prefix to
be already removed.
Read the given file decrypt it with the key and write the result to the string variable " result " . This expects the magic prefix to be already removed .
void decrypt(std::ifstream &ifs, std::string &result, const std::string &password) {
		if (ifs.bad())
			throw UnexpectedInputException("UTF8BasicCipherInputStream::open()",
										   "Error reading source file");
		size_t password_offset = 0;
		password_offset += 256*((unsigned char)(ifs.get())%256);
		password_offset += (unsigned char)(ifs.get())%256;
		for (size_t i=0; ifs.good(); ++i) {
			int c = ifs.get();
			if (ifs.good())
				result.push_back((char)(c ^ password[password_offset++%password.size()]));
		}
	}
void decrypt ( std :: ifstream & ifs , std :: string & result , const std :: string & password ) { if ( ifs . bad ( ) ) throw UnexpectedInputException ( " " , " " ) ; size_t password_offset = 0 ; password_offset += 256 * ( ( unsigned char ) ( ifs . get ( ) ) % 256 ) ; password_offset += ( unsigned char ) ( ifs . get ( ) ) % 256 ; for ( size_t i = 0 ; ifs . good ( ) ; ++ i ) { int c = ifs . get ( ) ; if ( ifs . good ( ) ) result . push_back ( ( char ) ( c ^ password [ password_offset ++ % password . size ( ) ] ) ) ; } }
Read the given file, decrypt it with the key, and write the result
 to the string variable "result".
Read the given file decrypt it with the key and write the result to the string variable " result " .
// Get the random "salt" -- this tells us what offset to start at for the 
 // password.
