Пример #1
0
        public void HideBytesInPng(Image innocuousBmp, string outputImageFileName, byte[] hiddenBytes)
        {
            hiddenBytes = ByteEncryptionUtil.EncryptSalsa20(hiddenBytes, _key);
            byte[] hiddenLengthBytes    = BitConverter.GetBytes(hiddenBytes.Length);
            byte[] hiddenCombinedBytes  = PngUtils.Combine(hiddenLengthBytes, hiddenBytes);
            byte[] rgbComponents        = PngUtils.RgbComponentsToBytes(innocuousBmp);
            byte[] encodedRgbComponents = EncodeBytes(hiddenCombinedBytes, rgbComponents);
            Bitmap encodedBmp           = PngUtils.ByteArrayToBitmap(encodedRgbComponents, innocuousBmp.Width, innocuousBmp.Height);

            encodedBmp.Save(outputImageFileName, ImageFormat.Png);
            encodedBmp.Dispose();
            innocuousBmp.Dispose();
        }
Пример #2
0
        public byte[] ReadHiddenBytesFromPng(string imageFileName)
        {
            Bitmap loadedEncodedBmp = new Bitmap(imageFileName);

            byte[]    loadedEncodedRgbComponents = PngUtils.RgbComponentsToBytes(loadedEncodedBmp);
            const int bytesInInt = 4;

            byte[] loadedHiddenLengthBytes = DecodeBytes(loadedEncodedRgbComponents, 0, bytesInInt);
            int    loadedHiddenLength      = BitConverter.ToInt32(loadedHiddenLengthBytes, 0);

            byte[] loadedHiddenBytes = DecodeBytes(loadedEncodedRgbComponents, bytesInInt, loadedHiddenLength);
            loadedEncodedBmp.Dispose();
            return(ByteEncryptionUtil.DecryptSalsa20(loadedHiddenBytes, _key));
        }