public List <DecryptedFile> Decrypt()
 {
     try
     {
         currentLock.LockBits();
         if (IsEncryptedImage)
         {
             List <DecryptedFile> files = new List <DecryptedFile>();
             int fileLength             = BitConverter.ToInt32(ReadBytes(128, 32), 0);
             int position = 160;
             for (int i = 0; i < fileLength; i++)
             {
                 string        extention = Encoding.ASCII.GetString(ReadBytes(position, 24));
                 int           fileSize  = BitConverter.ToInt32(ReadBytes(position + 24, 32), 0);
                 byte[]        data      = ReadBytes(position + 56, fileSize);
                 DecryptedFile file      = new DecryptedFile()
                 {
                     Data      = data,
                     Extention = extention
                 };
                 files.Add(file);
                 position += 56 + fileSize;
             }
             return(files);
         }
         return(null);
     }
     catch (Exception ex)
     {
     }
     finally
     {
         currentLock.UnlockBits();
     }
     return(null);
 }
        public void Encrypt(string[] encFiles, string saveLocation)
        {
            try
            {
                currentLock.LockBits();

                List <BitArray> files = new List <BitArray>();
                foreach (string path in encFiles)
                {
                    BitArray fileArray = GetFileBits(path);
                    files.Add(fileArray);
                }

                int  requiredBytes = TotalBits(files);
                bool changeSize    = MaxBitContent < requiredBytes;
                if (changeSize)
                {
                    Size requiredSize = GetRequiredImageSize(requiredBytes);
                    current     = ResizeImage(requiredSize.Width, requiredSize.Height);
                    currentLock = new LockBitmap(current);
                }

                //Add parity and size bits
                int position = 0;
                Write(startSequenceArr, ref position);
                Write(BitConverter.GetBytes(files.Count), ref position);

                //Fill pixels with file data
                int pos = 0;
                foreach (BitArray file in files)
                {
                    int    lastDot   = encFiles[pos].LastIndexOf(".");
                    string extention = encFiles[pos].Substring(lastDot + 1).PadRight(3);
                    if (extention.Length > 3)
                    {
                        extention = extention.Substring(0, 3);
                    }
                    Write(Encoding.ASCII.GetBytes(extention), ref position);
                    Write(BitConverter.GetBytes(file.Length), ref position);
                    Write(file, ref position);
                }

                Bitmap     newImg     = new Bitmap(current.Size.Width, current.Size.Height, PixelFormat.Format32bppArgb);
                LockBitmap newImgLock = new LockBitmap(newImg);
                newImgLock.LockBits();
                for (int x = 0; x < current.Size.Width; x++)
                {
                    for (int y = 0; y < current.Size.Height; y++)
                    {
                        newImgLock.SetPixel(x, y, currentLock.GetPixel(x, y));
                    }
                }
                newImgLock.UnlockBits();
                newImg.Save(saveLocation);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                currentLock.UnlockBits();
            }
        }