hide.py
hide.py copied to clipboard
Decoding gives error when the input file uses `./`
$ python hide.py -i ./test.png -f ./payload -a encode -p foobar
$ python hide.py -i ./output.png -a decode -p foobar
Saving decoded output as output./payload
Traceback (most recent call last):
File "hide.py", line 234, in <module>
main()
File "hide.py", line 227, in main
decode(args.image, password=args.password)
File "hide.py", line 141, in decode
with open("output"+os.extsep+header.fformat, 'wb') as outf:
IOError: [Errno 2] No such file or directory: 'output./payload'
I think the primitive filename parser assumes everything after . must be the extension, and saves it in the header when encoding. When it decodes the data it tries to create a file with an invalid extension.
Why not use os.path.splitext?