Using the class I posted in last post, I created 1 million in 7.3 secs on
my laptop and could find and decrypt record 500,000 in 1.5 milliseconds.
string path = @"\isbncrypt.txt";
byte[] key = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
6 };
byte[] iv = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
6 };
File.Delete(path);
MyRecords mr = new MyRecords(path, key, iv);
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
byte[] rec = new byte[32];
Stopwatch sw = new Stopwatch();
sw.Start();
for ( int i = 0; i < 1000000; i++ )
{
rec[0] = (byte)i;
mr.Add(rec);
}
sw.Stop();
Console.WriteLine("Time to create records:" +
sw.Elapsed.TotalSeconds.ToString());
sw.Start();
rec = mr.FindIndex(50000);
sw.Stop();
Console.WriteLine("Rec {0}:{1}", 500000,
BitConverter.ToString(rec));
Console.WriteLine("Time to find:" +
sw.Elapsed.TotalSeconds.ToString());
Time to create records:7.3629251
Rec
500000:20-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-
ms to find:1.5317
ticks to find:15317
--
William Stacey [MVP]
Caroline said:
Jon is getting the point.
I will access each encrypted record via a binary search on the pocket
pc.
I have tried this and have no problems with it, it's quite fast.
But the problem I am having is creating the encrypted strings using
CryptoStream on my laptop (or desktop). Last night I tried using the
close clause, it's faster, but still took about 18 hours to run. It
goes fast in the beginning, but than after the initial 8 mb it runs
slower and slower. The generated file is 183 MB total. I am going to try
using a memory profiling tool.
I think you're missing the aim - if I need to get to the last
record, I
have to decrypt everything up until that point with your scheme.
Most likely I am missing it. I am not getting getting the full story
from
Caroline so I try to read between the lines here. On one hand, she
says see
needs to seek, but then talks like she will enumerate all records
anyway.
Caroline, how will you access the records 1-1,000,000 or some random
order?
I haven't seen where it looks like she's going to be enumerating all
the records, other than in the sample code - which I just took to be
sample code which demonstrated the problem.
Note that this is going to be read on the compact framework by the way,
so even if reading 2 million records only took 8.5 seconds on your
laptop, reading that many on a mobile device could take a *lot* longer.