Exemplo n.º 1
0
        /// <summary>
        /// Extracts a byte from data
        /// </summary>
        /// <param name="data">Data containg bits</param>
        /// <returns>The byte hidden in data</returns>
        protected byte ExtractEx(byte[] data)
        {
            byte info = 0;

            ///We will read the LSB value from data and make it part of info
            ///As we hide LSB of message byte first therefore we start the loop from
            ///then i.e. end of the array to read MSB and then right shift it to store
            ///the next bit
            for (int i = data.Length; i > 0; i--)
            {
                ///Shift one bit to right side so the next bit can be set
                info <<= 0x1;
                info  |= Substitution.LsbValue(data[i - 1]);
            }

            return(info);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Extract length from host object
        /// </summary>
        /// <param name="stegoObject"></param>
        /// <returns></returns>
        protected int ExtractLength(IHostObject hostObject)
        {
            ///32 bytes of stego object will contain 4 bytes of legth information.
            ///We will read it byte by byte
            byte[] lengthInfo = new byte[4];

            for (int i = 0; i < 4; i++)
            {
                byte[] lengthBytes = new byte[8];
                hostObject.Read(lengthBytes, 0, lengthBytes.Length);

                ///The first byte in this array will contain LSB information. We will have to
                ///read MSB first
                for (int j = lengthBytes.Length; j > 0; j--)
                {
                    ///Shift one bit to right side so the next bit can be set
                    lengthInfo[i] <<= 0x1;
                    lengthInfo[i]  |= Substitution.LsbValue(lengthBytes[j - 1]);
                }
            }

            return(AppUtil.FromByteArray(lengthInfo));
        }