Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Ma5onic/893daa38b3f05f68e4127b426be379a8 to your computer and use it in GitHub Desktop.
Save Ma5onic/893daa38b3f05f68e4127b426be379a8 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.
# 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