Forked from reachsumit/Audio Steganography - receiver.py
Created
June 24, 2018 21:54
-
-
Save sumit-code/5c91613fc6a20931dcad933e105e80e8 to your computer and use it in GitHub Desktop.
Revisions
-
reachsumit created this gist
Jun 14, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ # Use wave package (native to Python) for reading the received audio file import wave song = wave.open("song_embedded.wav", mode='rb') # Convert audio to byte array frame_bytes = bytearray(list(song.readframes(song.getnframes()))) # Extract the LSB of each byte extracted = [frame_bytes[i] & 1 for i in range(len(frame_bytes))] # Convert byte array back to string string = "".join(chr(int("".join(map(str,extracted[i:i+8])),2)) for i in range(0,len(extracted),8)) # Cut off at the filler characters decoded = string.split("###")[0] # Print the extracted text print("Sucessfully decoded: "+decoded) song.close()