Programmatically "corrupt" an mp3 file
-
Hello I am trying to get my feet wet with I/O. Basically, I have an MP3 file that I want to "corrupt". At first, I thought merely adding some garbage bytes to the beginning would do the trick, but that doesnt work. For example,
FileStream fs = new FileStream("try1.avi" , FileMode.Open, FileAccess.Write); fs.WriteByte(123); fs.Flush(); fs.Close();
After examining the edited file with a hex-editor, I noticed that the byte is correctly being added to the start of the file. However, WinAmp still plays the mp3. Infact, I started directly shifting bytes around with the hex editor and realised that the file still plays! (albeit a little messed up) Further research shows that this resilience is due to the format of the MP3 itself. It turns out an Mp3 file is divided into frames (each frame consisting of a header and data) which are independent of each other. So... well.. anyone have any clever ideas how I can programmatically "corrupt" the Mp3 file? Ofcourse, I need to do it in such a way that I can reverse the process! Regards, -
Hello I am trying to get my feet wet with I/O. Basically, I have an MP3 file that I want to "corrupt". At first, I thought merely adding some garbage bytes to the beginning would do the trick, but that doesnt work. For example,
FileStream fs = new FileStream("try1.avi" , FileMode.Open, FileAccess.Write); fs.WriteByte(123); fs.Flush(); fs.Close();
After examining the edited file with a hex-editor, I noticed that the byte is correctly being added to the start of the file. However, WinAmp still plays the mp3. Infact, I started directly shifting bytes around with the hex editor and realised that the file still plays! (albeit a little messed up) Further research shows that this resilience is due to the format of the MP3 itself. It turns out an Mp3 file is divided into frames (each frame consisting of a header and data) which are independent of each other. So... well.. anyone have any clever ideas how I can programmatically "corrupt" the Mp3 file? Ofcourse, I need to do it in such a way that I can reverse the process! Regards, -
Why don't you encrypt the file ? this way its theoretically corrupted and you can reverse it with the right password
-
Interesting. Someone on another forums suggested a simple byte-reverse. That did the trick :) But encryption sounds cool too, I have no idea how to go about it tho. I'll look around. Guidance will be appreciated :) Thanks.
-
There are countless of samples and articles on how to encrypt files here on the code project
http://www.codeproject.com/dotnet/xcrypt.asp[^]
Vasudevan Deepak Kumar Personal Homepage Tech Gossips