Click here to Skip to main content
15,887,332 members
Home / Discussions / C#
   

C#

 
GeneralRe: Help Required in Steganography Project In C# Pin
nwr_mn19-Mar-06 8:08
nwr_mn19-Mar-06 8:08 
GeneralRe: Help Required in Steganography Project In C# Pin
Ed.Poore19-Mar-06 8:33
Ed.Poore19-Mar-06 8:33 
NewsRe: Help Required in Steganography Project In C# Pin
leppie19-Mar-06 18:21
leppie19-Mar-06 18:21 
QuestionSQLite DB Experience Anyone? Pin
redfish3419-Mar-06 5:44
redfish3419-Mar-06 5:44 
AnswerRe: SQLite DB Experience Anyone? Pin
Michael P Butler19-Mar-06 6:39
Michael P Butler19-Mar-06 6:39 
QuestionHelp Required in Steganography Project In C# Pin
nwr_mn19-Mar-06 5:43
nwr_mn19-Mar-06 5:43 
AnswerRe: Help Required in Steganography Project In C# Pin
Dave Kreskowiak19-Mar-06 7:06
mveDave Kreskowiak19-Mar-06 7:06 
GeneralRe: Help Required in Steganography Project In C# Pin
nwr_mn19-Mar-06 8:15
nwr_mn19-Mar-06 8:15 
using System;
using System.IO;
using System.Text;

namespace Steganography
{
public class BMPCoverFile : ICoverFile
{

private string fileName;

public BMPCoverFile(string fileName) {
this.fileName = fileName;
}

public IStegoFile CreateStegoFile(string stegoFileName, string message, string password) {

// Open the cover
FileStream inStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);

// Check whether the cover is a bmp file
char b = (char) inStream.ReadByte();
char m = (char) inStream.ReadByte();
if (!(b=='B' && m=='M'))
throw new Exception("The file is not a bitmap!");

// Check whether the bitmap is 24bit
byte[] buffer = new byte[2];
inStream.Seek(28, 0);
inStream.Read(buffer,0,2);
Int16 nBit = BitConverter.ToInt16(buffer, 0);
if (nBit!=24)
throw new Exception("The file is not a 24bit bitmap!");

// Read the header from the cover
int offset = 54; // Header Size
byte[] header = new byte[offset];
inStream.Seek(0, 0);
inStream.Read(header, 0, offset);

// Write the header to the stego file
FileStream outStream = new FileStream(stegoFileName, FileMode.Create, FileAccess.Write);

outStream.Write(header, 0, offset);

// Create the unicode encoding
UnicodeEncoding unicode = new UnicodeEncoding();

// Add the length of the message inside the first 4 bytes
byte[] messageBytes = AddLengthAhead(unicode.GetBytes(message));

// Encrypt the message
messageBytes = CryptoHelper.Encrypt(messageBytes, password);

// Encode the cover using the LSB method
inStream.Seek(offset, 0);
LSBHelper.Encode(inStream, messageBytes, outStream);

inStream.Close();
outStream.Close();

// Return a new BMPStegoFile
return new BMPStegoFile(stegoFileName, password);

}

private byte[] AddLengthAhead(byte[] messageBytes) {
int len = messageBytes.Length;
byte[] bLen = BitConverter.GetBytes(len);
byte[] ret = new byte[len + bLen.Length];
for (int i=0; i < bLen.Length; i++)
ret[i] = bLen[i];
for (int i=0; i < messageBytes.Length; i++)
ret[i+bLen.Length] = messageBytes[i];
return ret;
}

}

}

}

what is done in this code ?? it has been commented as Adding message bytes to the start of the pixels of the Bitmap.

AMAN ANWAR
GeneralRe: Help Required in Steganography Project In C# Pin
Dave Kreskowiak19-Mar-06 12:42
mveDave Kreskowiak19-Mar-06 12:42 
AnswerRe: WinForms painting issue Pin
chloh19-Mar-06 5:13
chloh19-Mar-06 5:13 
Questionreflexon Pin
vatzcar19-Mar-06 2:48
vatzcar19-Mar-06 2:48 
AnswerRe: reflexon Pin
Guffa19-Mar-06 3:01
Guffa19-Mar-06 3:01 
GeneralRe: reflexon Pin
vatzcar19-Mar-06 5:20
vatzcar19-Mar-06 5:20 
AnswerRe: reflexon Pin
[Marc]19-Mar-06 6:38
[Marc]19-Mar-06 6:38 
GeneralRe: reflexon Pin
vatzcar19-Mar-06 17:46
vatzcar19-Mar-06 17:46 
GeneralRe: reflexon Pin
vatzcar19-Mar-06 17:47
vatzcar19-Mar-06 17:47 
QuestionPausing voice on the click of a button Pin
Annie Fernando19-Mar-06 2:03
Annie Fernando19-Mar-06 2:03 
AnswerRe: Pausing voice on the click of a button Pin
CWIZO19-Mar-06 5:39
CWIZO19-Mar-06 5:39 
QuestionRe: Pausing voice on the click of a button Pin
Annie Fernando19-Mar-06 7:15
Annie Fernando19-Mar-06 7:15 
AnswerRe: Pausing voice on the click of a button Pin
Annie Fernando19-Mar-06 9:17
Annie Fernando19-Mar-06 9:17 
QuestionHow to refresh a DataView ? Pin
chloh19-Mar-06 1:33
chloh19-Mar-06 1:33 
QuestionPropertyGrid: Problem viewing arrays Pin
mitul198319-Mar-06 0:22
mitul198319-Mar-06 0:22 
AnswerRe: PropertyGrid: Problem viewing arrays Pin
mitul198319-Mar-06 2:10
mitul198319-Mar-06 2:10 
QuestionFloating panes Pin
deepscyberpulse18-Mar-06 21:48
deepscyberpulse18-Mar-06 21:48 
AnswerRe: Floating panes Pin
Shiby19-Mar-06 1:57
Shiby19-Mar-06 1:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.