-
Notifications
You must be signed in to change notification settings - Fork 2
/
hidewave.py
executable file
·53 lines (49 loc) · 1.66 KB
/
hidewave.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
# imports
import os
import wave
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-f', help='Select Audio File', dest='audiofile')
parser.add_argument('-m', help='Enter your Secret Message', dest='secretmsg')
parser.add_argument('-o', help='Your Output file path and name', dest='outputfile')
args = parser.parse_args()
af = args.audiofile
string = args.secretmsg
output = args.outputfile
arged = False
if af and string and output:
arged = True
def cls():
os.system("clear")
def help():
print("\033[92mHide Your Secret Message in Audio Wave File.\033[0m")
print ('''usage: HiddenWave.py [-h] [-f AUDIOFILE] [-m SECRETMSG] [-o OUTPUTFILE]
optional arguments:
-h, --help show this help message and exit
-f AUDIOFILE Select Audio File
-m SECRETMSG Enter your message
-o OUTPUTFILE Your output file path and name''')
def em_audio(af, string, output):
if not arged:
help()
else:
print ("Please wait...")
waveaudio = wave.open(af, mode='rb')
frame_bytes = bytearray(list(waveaudio.readframes(waveaudio.getnframes())))
string = string + int((len(frame_bytes)-(len(string)*8*8))/8) *'#'
bits = list(map(int, ''.join([bin(ord(i)).lstrip('0b').rjust(8,'0') for i in string])))
for i, bit in enumerate(bits):
frame_bytes[i] = (frame_bytes[i] & 254) | bit
frame_modified = bytes(frame_bytes)
with wave.open(output, 'wb') as fd:
fd.setparams(waveaudio.getparams())
fd.writeframes(frame_modified)
waveaudio.close()
print ("Done...")
cls()
try:
em_audio(af, string, output)
except:
print ("Something went wrong!! try again")
quit('')