-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.py
37 lines (29 loc) · 935 Bytes
/
sample.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
import stegwrapper
import argparse
MODE_SHOW = 'show'
MODE_HIDE = 'hide'
parser = argparse.ArgumentParser(description='Hide or extract a file in/from a jpg.')
parser.add_argument('mode', choices=[MODE_SHOW, MODE_HIDE], help="Hide or extract a file.")
parser.add_argument('-f', help="The file to hide or to write into.")
parser.add_argument('image', nargs=1, help='A jpg file')
arg = parser.parse_args()
imageFile = str(arg.image[0])
mode = arg.mode
datei = str(arg.f)
if mode == MODE_HIDE:
if not datei:
print "Please specify a file to hide."
sys.exit(1)
p = stegwrapper.picture.open(imageFile, "w")
print "Enter some characters to hide to hide:"
a = raw_input()
print "Please wait"
p.write(a)
p.save(datei)
else:
p = stegwrapper.picture.open(imageFile)
print "Read how many bytes?"
a = int(raw_input())
print repr(p.read(a))
#im = Image.open(imageFile)
#im.getdata()