Solved

memory map compression encryption

Posted on 2011-03-19
5
591 Views
Last Modified: 2012-05-11
Guys,

Is it possible to use the .Net 4 Memory mapping solution with an encrypted/compressed file on disk?  Im having trouble and feel it may not be possible, Ive googled around and there doesnt seem to be a lot on this specific point, heres a test code snippet Ive setup (which compiles) but doesnt run.  Note if I use a filestream and avoid the memory map idea it works properly, In this scenario the accessor is grabbing everything as Im using a small file for demo purpose.  FYI its getting to where the "line = sReader.ReadLine();" before hanging (theres no exception throwing, I have to exit VS2010 to stop it) cheers

 I need a heads up on whether it can be done, and if so how to alter this snippet to work properly, cheers
		private string GetLastDateInFile(string filePath)
			{
			string[] lineString;
			CryptoStream decryptStream;
			C1ZStreamReader compressReader = null;
			string line;
			string[] lastLineString = null;

			// If the file does not exist, return ""
			if (!File.Exists(filePath))
				return "";

			FileInfo fileInfo = new FileInfo(filePath);

			using (MemoryMappedFile memoryMappedFile = MemoryMappedFile.CreateFromFile(filePath, FileMode.Open))
					{
					using (MemoryMappedViewStream accessor = memoryMappedFile.CreateViewStream())
						{
						// open expander stream on compressed source
						decryptStream = new CryptoStream(accessor, Global.DECRYPTOR_MAIN, CryptoStreamMode.Read);
						compressReader = new C1ZStreamReader(decryptStream);

						using (StreamReader sReader = new StreamReader(compressReader))
							{
							line = sReader.ReadLine();

							while ((line = sReader.ReadLine()) != null)
								{
								lineString = line.Split(',');

								if (lineString.Length < 13)
									continue;

								// remember the last
								lastLineString = lineString;
								}
							}
						}
					}

			// return the datestring
			return lastLineString[1];
			}

Open in new window

0
Comment
Question by:TheMoog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 11

Expert Comment

by:lenordiste
ID: 35175877
What software is handling your disk's encryption?
Can you actually try your code without handling the encryption/decryption?
0
 

Accepted Solution

by:
TheMoog earned 0 total points
ID: 35179557
The answer was that the C1 compression type was not compatible.  When that was substituted with a GZip compression type it all works perfectly.  I should of guessed that right at the start.

Thanks anyway.

And the answer to my question is yes you can encrypt and compress using memory mapping which is cool
0
 
LVL 11

Expert Comment

by:lenordiste
ID: 35179822
good to know !
0
 
LVL 27

Expert Comment

by:Tolomir
ID: 35422456
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a financial services provider, your business is impacted by two of the strictest federal regulations on record: the Sarbanes-Oxley Act and the Gramm-Leach-Bliley Act. Correctly implementing faxing into your organization to provide secure, real-ti…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question