Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hello, i need to convert an audio file which may be wav or mp3 or any audio format to a byte array then encrypt every byte with a key which i choose...i am trying to find how to convert an audio file to byte array but i cant find anything...any help?
Posted

1 solution

Simple:
VB
Dim data As Byte() = File.ReadAllBytes(path)
 
Share this answer
 
Comments
Aseel_Y. 14-Feb-13 12:52pm    
Thank you.. that helped me :)
OriginalGriff 14-Feb-13 14:06pm    
You're welcome!
Aseel_Y. 15-Feb-13 4:40am    
I have one more request please..
I converted the audio files to byte array, then as I needed to convert it to binary and XOr it with a fixed key I chose, after which I converted the XOred strings to byte array again.
The problem I faced was that I needed to save my edited byte array to audio file again, the file was successfully created, but it wouldn't play in any player..
I used the code:

Dim nf As FileStream
nf = New FileStream("test2.wma", FileMode.Create)
nf.Write(bytes_e, 0, bytes_e.Length)
nf.Close()

is it normal that it wouldn't play after the transformation, or I should do something to adjust it?
Thank you...
Aseel_Y. 15-Feb-13 4:52am    
Now I took the transformed file and XOred it with the same key again (converted to original again) and played the file and it perfectly worked.. so maybe it's not suppose to play when it's content is changed?
OriginalGriff 15-Feb-13 4:56am    
No, of course it's not supposed to play if you just XOR it once!
Would you expect to read a message from me if I XORed each byte with 0xCC once? :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900