Пример #1
0
        /// <summary>
        /// Decrypts an text hidden inside the image.
        /// </summary>
        /// <param name="image">The bytes of the image where the message is hidden.</param>
        /// <param name="skipAlpha">Should the alpha channel remain untouched?.</param>
        /// <returns>An array of bytes with the text that was hidden.</returns>
        private static byte[] DecryptStringMessage(byte[] image, bool skipAlpha)
        {
            //Transfome bytes to bits.
            BitArray imageBits = new BitArray(image);

            //Get the size of the message we'll have to decrypt, at the beginning of the image.
            int messageSize = DecryptionHelper.GetMessageSize(imageBits, 0, skipAlpha);

            //Empty array of bits the size of the message size we just got.
            BitArray messageBits = new BitArray(messageSize);

            //Decrypts the message.

            byte[] messageDecrypted = DecryptionHelper.GetDecryptedMessage(imageBits, messageBits,
                                                                           SizeInfo.Text, skipAlpha);

            return(messageDecrypted);
        }
Пример #2
0
        /// <summary>
        /// Decrypts an image hidden inside the image.
        /// </summary>
        /// <param name="image">The bytes of the image where the message is hidden.</param>
        /// <param name="skipAlpha">Should the alpha channel remain untouched?.</param>
        /// <returns>An array of bytes with the image that was hidden.</returns>
        private static byte[] DecryptImageMessage(byte[] image, bool skipAlpha)
        {
            //Transform bytes to bits.
            BitArray imageBits = new BitArray(image);

            //Get the size of the message we'll have to decrypt, at the beginning of the image.
            Steganography.embeddedWidth  = DecryptionHelper.GetMessageSize(imageBits, 0, skipAlpha);
            Steganography.embeddedHeight = DecryptionHelper.GetMessageSize(imageBits, 24 * 8, skipAlpha);

            //Empty array of bits the size of the message size we just got.
            BitArray messageBits = new BitArray(Steganography.embeddedWidth * Steganography.embeddedHeight * 32);

            //Decrypts the message.

            byte[] messageDecrypted = DecryptionHelper.GetDecryptedMessage(imageBits, messageBits,
                                                                           SizeInfo.Image, skipAlpha);

            return(messageDecrypted);
        }