/// <summary> /// Hide data in buffer /// </summary> /// <param name="buffer">Buffer in which data is to be hidden</param> /// <param name="bufferLen">Length of buffer</param> protected virtual unsafe int HideData(byte *buffer, int bufferLen) { int offset = 0; while ((offset + 8) < bufferLen) { iter++; int next = this._message.NextByte(); if (next == -1) { this._processing = ProcessingType.Done; ///No more data to hide break; } byte data = (byte)next; ///Get 8 bytes of cover message and ///hide a byte of data in it for (int i = 0; i < 8; i++) { byte cover = buffer[offset]; ///Right shift the data to get next byte and AND with 1 = 00000001 Substitution.LsbSubstitute(ref cover, (byte)(((data >> i) & 0x1))); buffer[offset] = cover; offset++; } } return(offset); }
/// <summary> /// The secret message to be hidden in cover object /// </summary> /// <param name="save">Stream in which stego object is saved</param> ///<param name="data">Data to hide</param> ///<returns>Return the number of bytes saved in data. 0 means ///the hiding is complete</returns> protected int HideData(Stream save, byte data) { int i = 0; ///Get 8 bytes of cover message and ///hide a byte of data in it for (; i < 8; i++) { int next = this.HostObject.Read(); ///No more cover bytes to save data in if (next == -1) { return(i); } byte cover = (byte)next; ///Right shift the data to get next byte and AND with 1 = 00000001 Substitution.LsbSubstitute(ref cover, (byte)(((data >> i) & 0x1))); save.WriteByte(cover); } return(i); }