Пример #1
0
void ApplicationOctetStreamPart::Send (Socket & socket) const
{
    socket.SendLine ("Content-Type: application/octet-stream;");
    socket.SendLine ("\tname=\"" + _filename + "\"");
    socket.SendLine ("Content-Transfer-Encoding: base64");
    socket.SendLine ("Content-Disposition: attachment;");
    socket.SendLine ("\tfilename=\"" + _filename + "\"");
    socket.SendLine ();

    MemFileReadOnly srcFile (_attPath.ToString ());
    Smtp::Output output (socket);
    Base64::Encode (srcFile.GetBuf (), srcFile.GetBufSize (), output);

    socket.SendLine ();
}
Пример #2
0
	void CryptographyTest (std::ostream & out)
	{
		out << std::endl << "Test of cryptography." << std::endl;

		std::string password ("secret");
		// empty strings not allowed
		{
		}
		// one character string
		{
			std::string test ("x");
			RunTest (test, password, out);
		}
		// internal buffer boundaries
		{
			Crypt::Streamer auxStreamer (password);
			unsigned int internalBufSize = auxStreamer._buf.size ();
			for (unsigned int size = internalBufSize - 1; size <= internalBufSize + 1; ++size)
			{
				std::string test (size, 'x');
				RunTest (test, password, out);
			}	
			unsigned int internalBufSizeX10 = 10 * internalBufSize;
			for (unsigned int size = internalBufSizeX10 - 1; 
				 size <= internalBufSizeX10 + 1; 
				 ++size)
			{
				std::string test (size, 'x');
				RunTest (test, password, out);
			}	
		}
		// large file
		{
			SystemFilesPath systemPath;
			systemPath.DirDown ("system32");
			MemFileReadOnly in (systemPath.GetFilePath ("shell32.dll"));
			char const * buf = in.GetBuf ();
			std::string contents;
			std::copy (buf, buf + in.GetBufSize (), std::back_inserter (contents));
			RunTest (contents, password, out);
		}

		out << "Passed." << std::endl;
	}