Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sumit-code/5c91613fc6a20931dcad933e105e80e8 to your computer and use it in GitHub Desktop.
Save sumit-code/5c91613fc6a20931dcad933e105e80e8 to your computer and use it in GitHub Desktop.

Revisions

  1. @reachsumit reachsumit created this gist Jun 14, 2018.
    16 changes: 16 additions & 0 deletions Audio Steganography - receiver.py
    Original 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()