Пример #1
0
        private void DecipherWithoutFiltering(ImageBlockCipher imageBlockCipher)
        {
            List <Chunk> parsedChunks     = ReadAndParseChunks();
            List <Chunk> decipheredChunks = imageBlockCipher.DecipherWithoutFiltering(parsedChunks);

            PNGFile.Write(SaveFileDialog.FileName, decipheredChunks);
        }
Пример #2
0
        public void ShouldWritePNGFile()
        {
            string       filePath        = @"../../../Data/Plan.png";
            List <Chunk> chunks          = PNGFile.Read(filePath);
            string       filePathToWrite = @"../../../Data/PlanSaved.png";

            PNGFile.Write(filePathToWrite, chunks);
        }
        public void ShouldDecipherImageWithoutFiltering()
        {
            string       filePathToRead   = @"../../../Data/square_wave_encrypted.png";
            string       filePathToWrite  = @"../../../Data/square_wave_decrypted.png";
            List <Chunk> chunks           = PNGFile.Read(filePathToRead);
            List <Chunk> parsedChunks     = ChunkParser.Parse(chunks);
            List <Chunk> decipheredChunks = imageBlockCipher.DecipherWithoutFiltering(parsedChunks);

            PNGFile.Write(filePathToWrite, decipheredChunks);
        }
Пример #4
0
        public void ShouldCipherLenaImageWithoutFiltering()
        {
            string       filePathToRead  = @"../../../Data/Lena.png";
            string       filePathToWrite = @"../../../Data/Lena_encrypted.png";
            List <Chunk> chunks          = PNGFile.Read(filePathToRead);
            List <Chunk> parsedChunks    = ChunkParser.Parse(chunks);
            List <Chunk> cipheredChunks  = imageBlockCipher.CipherWithoutFiltering(parsedChunks);

            PNGFile.Write(filePathToWrite, cipheredChunks);
        }
Пример #5
0
        public void ShouldConcatAndThenSplitImage()
        {
            string       filePath       = @"../../../Data/lena.png";
            List <Chunk> chunks         = PNGFile.Read(filePath);
            List <Chunk> parsedChunks   = ChunkParser.Parse(chunks);
            int          firstIdatIndex = parsedChunks.TakeWhile(chunk => !IsIDAT(chunk)).Count();
            List <IDAT>  idats          = parsedChunks.Where(IsIDAT).Select(chunk => (IDAT)chunk).ToList();

            byte[]       bytes        = IDATConverter.ConcatToBytes(idats);
            List <Chunk> resultIdats  = IDATConverter.SplitToIDATs(bytes).Select(idat => (Chunk)idat).ToList();
            List <Chunk> resultChunks = parsedChunks.Where(chunk => !IsIDAT(chunk)).ToList();

            resultChunks.InsertRange(firstIdatIndex, resultIdats);
            PNGFile.Write(@"../../../Data/lenaConverted.png", resultChunks);
        }