Created
June 14, 2018 14:43
-
-
Save reachsumit/583c76ffd740e1a952d65da3c676931f to your computer and use it in GitHub Desktop.
This code contains a demo for Audio Steganography. It is to be used by the receiver end, to extract the secret text embedded in the audio file.
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 characters
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment