Demo entry 6645819

LinearTest

   

Submitted by John on Oct 11, 2017 at 23:09
Language: C#. Code size: 2.2 kB.

public static void LinearTest(){
            int variation = 10;//This is our 'seed' but is basic(See (Section Name) to see
why this number doesn't really matter)
            string[] total = File.ReadAllLines("AllData.txt");
            string[] fakes = File.ReadAllLines("FakeData.txt");
            string[] reals = File.ReadAllLines("RealData.txt");// Reads all of the data
            string[] corrected = new string[total.Length];// Our 'encrypted' data
            Stopwatch watch = new Stopwatch();
            Console.WriteLine("Building total array");
            watch.Start();//Start timing the encryption system
            int f = 0;
            int r = 0;
            for(int i = 0; i < total.Length/variation; i++){//Insert a fake data into every
'variation' and fill the rest with real data
                corrected[variation * i] = fakes[f];
                f++;
                for(int j = 1; j < variation; j++){
                    corrected[variation * i + j] = reals[r];// inserts real data
                    r++;
                }
            }
            if(corrected.Length!= total.Length) Console.WriteLine("ERROR NOT RIGHT SIZE");//
Tests for errors
            watch.Stop();// Encryption is finished
            File.AppendAllText("Info.txt","\nTime for Linear Encryption: " +
watch.ElapsedMilliseconds + "ms");// Save the time
            Stopwatch swatch = new Stopwatch();
            string[] real = new string[reals.Length];// Our decrypted array
            swatch.Start();//Start timing the decryption system
            int c = 0;
            for(int i = 0; i < corrected.Length; i++){
                if(i % variation != 0){// Add all of the real data
                    real[c] = corrected[i];
                    c++;
                }
            }
            swatch.Stop();// Decyrption is finished
            File.AppendAllText("Info.txt","\nTime for Linear Decryption: " +
swatch.ElapsedMilliseconds + "ms");// Add timing data
            File.WriteAllLines("LinearReals.txt", real);// Print the real data to verify the
system was correct
            Console.WriteLine("Finished");
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).