•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Legacy and Other Languages section within the Software Development category of DaniWeb, a massive community of 422,420 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,280 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Legacy and Other Languages advertiser: Programming Forums
Views: 493 | Replies: 0
![]() |
•
•
Join Date: May 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
which hide text and audio
please help me
code :
-------------------------------------------------------------------------------
public void Hide(Stream messageStream, Stream keyStream){
byte[] waveBuffer = new byte;
byte message, bit, waveByte;
int messageBuffer; //receives the next byte of the message or -1
int keyByte; //distance of the next carrier sample
//loop over the message, hide each byte
while( (messageBuffer=messageStream.ReadByte()) >= 0 ){
//read one byte of the message stream
message = (byte)messageBuffer;
//for each bit in [message]
for(int bitIndex=0; bitIndex<8; bitIndex++){
//read a byte from the key
keyByte = GetKeyValue(keyStream);
//skip a couple of samples
for(int n=0; n<keyByte-1; n++){
//copy one sample from the clean stream to the carrier stream
sourceStream.Copy(
waveBuffer, 0,
waveBuffer.Length, destinationStream);
}
//read one sample from the wave stream
sourceStream.Read(waveBuffer, 0, waveBuffer.Length);
waveByte = waveBuffer;
//get the next bit from the current message byte...
bit = (byte)(((message & (byte)(1 << bitIndex)) > 0) ? 1 : 0);
//...place it in the last bit of the sample
if((bit == 1) && ((waveByte % 2) == 0)){
waveByte += 1;
}else if((bit == 0) && ((waveByte % 2) == 1)){
waveByte -= 1;
}
waveBuffer = waveByte;
//write the result to destinationStream
destinationStream.Write(waveBuffer, 0, bytesPerSample);
}
}
//copy the rest of the wave without changes
//...
}
--------------------------------------
Extracting the Message
public void Extract(Stream messageStream, Stream keyStream){
byte[] waveBuffer = new byte;
byte message, bit, waveByte;
int messageLength = 0; //expected length of the message
int keyByte; //distance of the next carrier sample
while( (messageLength==0 || messageStream.Length<messageLength) ){
//clear the message-byte
message = 0;
//for each bit in [message]
for(int bitIndex=0; bitIndex<8; bitIndex++){
//read a byte from the key
keyByte = GetKeyValue(keyStream);
//skip a couple of samples
for(int n=0; n<keyByte; n++){
//read one sample from the wave stream
sourceStream.Read(waveBuffer, 0, waveBuffer.Length);
}
waveByte = waveBuffer;
//get the last bit of the sample...
bit = (byte)(((waveByte % 2) == 0) ? 0 : 1);
//...write it into the message-byte
message += (byte)(bit << bitIndex);
}
//add the re-constructed byte to the message
messageStream.WriteByte(message);
if(messageLength==0 && messageStream.Length==4){
//first 4 bytes contain the message's length
//...
}
}
}
-------------------
please help me
code :
-------------------------------------------------------------------------------
public void Hide(Stream messageStream, Stream keyStream){
byte[] waveBuffer = new byte;
byte message, bit, waveByte;
int messageBuffer; //receives the next byte of the message or -1
int keyByte; //distance of the next carrier sample
//loop over the message, hide each byte
while( (messageBuffer=messageStream.ReadByte()) >= 0 ){
//read one byte of the message stream
message = (byte)messageBuffer;
//for each bit in [message]
for(int bitIndex=0; bitIndex<8; bitIndex++){
//read a byte from the key
keyByte = GetKeyValue(keyStream);
//skip a couple of samples
for(int n=0; n<keyByte-1; n++){
//copy one sample from the clean stream to the carrier stream
sourceStream.Copy(
waveBuffer, 0,
waveBuffer.Length, destinationStream);
}
//read one sample from the wave stream
sourceStream.Read(waveBuffer, 0, waveBuffer.Length);
waveByte = waveBuffer;
//get the next bit from the current message byte...
bit = (byte)(((message & (byte)(1 << bitIndex)) > 0) ? 1 : 0);
//...place it in the last bit of the sample
if((bit == 1) && ((waveByte % 2) == 0)){
waveByte += 1;
}else if((bit == 0) && ((waveByte % 2) == 1)){
waveByte -= 1;
}
waveBuffer = waveByte;
//write the result to destinationStream
destinationStream.Write(waveBuffer, 0, bytesPerSample);
}
}
//copy the rest of the wave without changes
//...
}
--------------------------------------
Extracting the Message
public void Extract(Stream messageStream, Stream keyStream){
byte[] waveBuffer = new byte;
byte message, bit, waveByte;
int messageLength = 0; //expected length of the message
int keyByte; //distance of the next carrier sample
while( (messageLength==0 || messageStream.Length<messageLength) ){
//clear the message-byte
message = 0;
//for each bit in [message]
for(int bitIndex=0; bitIndex<8; bitIndex++){
//read a byte from the key
keyByte = GetKeyValue(keyStream);
//skip a couple of samples
for(int n=0; n<keyByte; n++){
//read one sample from the wave stream
sourceStream.Read(waveBuffer, 0, waveBuffer.Length);
}
waveByte = waveBuffer;
//get the last bit of the sample...
bit = (byte)(((waveByte % 2) == 0) ? 0 : 1);
//...write it into the message-byte
message += (byte)(bit << bitIndex);
}
//add the re-constructed byte to the message
messageStream.WriteByte(message);
if(messageLength==0 && messageStream.Length==4){
//first 4 bytes contain the message's length
//...
}
}
}
-------------------
Last edited by abdullilah : May 23rd, 2008 at 2:18 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Legacy and Other Languages Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access activation api blogger blogging blogs code code injection combo dani daniweb data debugging development dreamweaver dropdownlist epilepsy gdata google gpl griefers hackers html innovation javascript key linux microsoft module net news openbsd product programming reuse rss serial source tags vista web wysiwyg xml
- New to Assembly (Assembly)
- adding bit stuffing in NRZI algorithms (matlab) (Legacy and Other Languages)
Other Threads in the Legacy and Other Languages Forum
- Previous Thread: Qbasical Hangman
- Next Thread: help with MATLAB (i know it isn't c++)


Linear Mode