public string Encode(string src, ISecretMessage message, int passHash, int lsbIndicator = 3)
        {
            if (string.IsNullOrEmpty(src))
            {
                throw new ArgumentNullException(nameof(src));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (lsbIndicator < 0 || lsbIndicator > 8)
            {
                throw new ArgumentException(nameof(lsbIndicator));
            }

            InitializeEncoding(src, message, passHash, lsbIndicator);

            if (!IsEncryptionPossible())
            {
                CleanupEncoding();
                throw new ContentLengthException();
            }
            if (!DoesCoverFitType())
            {
                CleanupEncoding();
                throw new BadImageFormatException();
            }

            var result = EncodingAlgorithm(src, message);

            CleanupEncoding();

            return result;
        }
Ejemplo n.º 2
0
        public string Encode(string src, ISecretMessage message, int passHash, int lsbIndicator = 3)
        {
            if (string.IsNullOrEmpty(src))
            {
                throw new ArgumentNullException(nameof(src));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (lsbIndicator < 0 || lsbIndicator > 8)
            {
                throw new ArgumentException(nameof(lsbIndicator));
            }

            InitializeEncoding(src, message, passHash, lsbIndicator);

            if (!IsEncryptionPossible())
            {
                CleanupEncoding();
                throw new ContentLengthException();
            }
            if (!DoesCoverFitType())
            {
                CleanupEncoding();
                throw new BadImageFormatException();
            }

            var result = EncodingAlgorithm(src, message);

            CleanupEncoding();

            return(result);
        }
Ejemplo n.º 3
0
 protected override void InitializeEncoding(string src, ISecretMessage message, int passHash, int lsbIndicator)
 {
     base.InitializeEncoding(src, message, passHash, lsbIndicator);
     LsbIndicator = lsbIndicator;
     BitIndex     = 0;
     ByteIndex    = 0;
     Bytes        = message.Convert();
 }
 protected override string EncodingAlgorithm(string src, ISecretMessage message)
 {
     var data = message.Convert();
     var file = FileManager.CopyImageToTmp(src);
     using (var sw = new StreamWriter(File.Open(file, FileMode.Append)))
     {
         sw.Write("\n");
         sw.Write("\n");
         sw.Write("\n");
         sw.Write(ConvertHelper.Convert(data));
     }
     return file;
 }
        protected override string EncodingAlgorithm(string src, ISecretMessage message)
        {
            var data = message.Convert();
            var file = FileManager.CopyImageToTmp(src);

            using (var sw = new StreamWriter(File.Open(file, FileMode.Append)))
            {
                sw.Write("\n");
                sw.Write("\n");
                sw.Write("\n");
                sw.Write(ConvertHelper.Convert(data));
            }
            return(file);
        }
Ejemplo n.º 6
0
 protected override string EncodingAlgorithm(string src, ISecretMessage message)
 {
     var tmp = FileManager.CopyImageToTmp(src);
     using (var bmp = new Bitmap(src))
     {
         var item = bmp.PropertyItems.OrderByDescending(x => x.Id).First();
         item.Id = item.Id + 1;
         item.Len = Bytes.Length;
         item.Value = Bytes;
         item.Type = 1;
         bmp.SetPropertyItem(item);
         bmp.Save(tmp);
     }
     return tmp;
 }
Ejemplo n.º 7
0
        protected override string EncodingAlgorithm(string src, ISecretMessage message)
        {
            var tmp = FileManager.CopyImageToTmp(src);

            using (var bmp = new Bitmap(src))
            {
                var item = bmp.PropertyItems.OrderByDescending(x => x.Id).First();
                item.Id    = item.Id + 1;
                item.Len   = Bytes.Length;
                item.Value = Bytes;
                item.Type  = 1;
                bmp.SetPropertyItem(item);
                bmp.Save(tmp);
            }
            return(tmp);
        }
Ejemplo n.º 8
0
        protected override void InitializeEncoding(string src, ISecretMessage message, int passHash, int lsbIndicator)
        {
            base.InitializeEncoding(src, message, passHash, lsbIndicator);
            var filter = new Laplace(Bitmap, LsbIndicator, 8);
            IDictionary <Pixel, int> filtered = new Dictionary <Pixel, int>();

            for (var x = 0; x < Bitmap.Width; x++)
            {
                for (var y = 0; y < Bitmap.Height; y++)
                {
                    filtered.Add(new Pixel(x, y), filter.GetValue(x, y));
                }
            }
            var ordered = filtered.OrderByDescending(key => key.Value);

            mLaplaceValues = ordered;
        }
Ejemplo n.º 9
0
        protected override string EncodingAlgorithm(string src, ISecretMessage message)
        {
            var tmp = FileManager.CopyImageToTmp(src);

            try
            {
                if (!EncodingIteration())
                {
                    throw new SystemException();
                }
            }
            finally
            {
                Cleanup();
                Bitmap.Source.Save(tmp);
            }
            return(tmp);
        }
Ejemplo n.º 10
0
 protected virtual void InitializeEncoding(string src, ISecretMessage message, int passHash, int lsbIndicator)
 {
     Bitmap   = LockBitmap(src);
     PassHash = passHash;
 }
Ejemplo n.º 11
0
 protected override void InitializeEncoding(string src, ISecretMessage message, int passHash, int lsbIndicator)
 {
     base.InitializeEncoding(src, message, passHash, lsbIndicator);
     GenerateShips();
 }
Ejemplo n.º 12
0
        protected override string EncodingAlgorithm(string src, ISecretMessage message)
        {
            var palette = Bitmap.Source.Palette;

            throw new NotImplementedException();
        }
 protected virtual void InitializeEncoding(string src, ISecretMessage message, int passHash, int lsbIndicator)
 {
     Bitmap = LockBitmap(src);
     PassHash = passHash;
 }
 protected abstract string EncodingAlgorithm(string src, ISecretMessage message);
Ejemplo n.º 15
0
 protected override void InitializeEncoding(string src, ISecretMessage message, int passHash, int lsbIndicator)
 {
     base.InitializeEncoding(src, message, passHash, lsbIndicator);
     GenerateShips();
 }
Ejemplo n.º 16
0
        protected override string EncodingAlgorithm(string src, ISecretMessage message)
        {
            var tmp = FileManager.CopyImageToTmp(src);

            try
            {
                if (!EncodingIteration())
                {
                    throw new SystemException();
                }
            }
            finally
            {
                Cleanup();
                Bitmap.Source.Save(tmp);
            }
            return tmp;
        }
Ejemplo n.º 17
0
 protected abstract string EncodingAlgorithm(string src, ISecretMessage message);
Ejemplo n.º 18
0
 protected override void InitializeEncoding(string src, ISecretMessage message, int passHash, int lsbIndicator)
 {
     base.InitializeEncoding(src, message, passHash, lsbIndicator);
     var filter = new Laplace(Bitmap, LsbIndicator, 8);
     IDictionary<Pixel, int> filtered = new Dictionary<Pixel, int>();
     for (var x = 0; x < Bitmap.Width; x++)
     {
         for (var y = 0; y < Bitmap.Height; y++)
         {
             filtered.Add(new Pixel(x, y), filter.GetValue(x, y));
         }
     }
     var ordered = filtered.OrderByDescending(key => key.Value);
     mLaplaceValues = ordered;
 }
Ejemplo n.º 19
0
 protected override void InitializeEncoding(string src, ISecretMessage message, int passHash, int lsbIndicator)
 {
     base.InitializeEncoding(src, message, passHash, lsbIndicator);
     mPixels = new HashSet <Pixel>();
     Random  = new Random(PassHash);
 }
Ejemplo n.º 20
0
 protected override void InitializeEncoding(string src, ISecretMessage message, int passHash, int lsbIndicator)
 {
     base.InitializeEncoding(src, message, passHash, lsbIndicator);
     mPixels = new HashSet<Pixel>();
     Random = new Random(PassHash);
 }
Ejemplo n.º 21
0
 protected override void InitializeEncoding(string src, ISecretMessage message, int passHash, int lsbIndicator)
 {
     base.InitializeEncoding(src, message, passHash, lsbIndicator);
     LsbIndicator = lsbIndicator;
     BitIndex = 0;
     ByteIndex = 0;
     Bytes = message.Convert();
 }
Ejemplo n.º 22
0
 protected override string EncodingAlgorithm(string src, ISecretMessage message)
 {
     var palette = Bitmap.Source.Palette;
     throw new NotImplementedException();
 }