def extractData(): algo = extractAlgo.get() if(algo == "Blowfish" or algo == "LSB"): raw = lsb.decodeImage(extractInputFile) if(algo == "Blowfish"): raw = blowfish_algo.decrypt(raw) elif(algo == "BPCS"): raw = bpcs.decode(extractInputFile, "", alpha) elif(algo == "DCT"): d = DCT(extractInputFile) raw = d.DCTDe() eim=Image.open(extractInputFile) eim = eim.resize((100, 75), Image.ANTIALIAS) rphoto=ImageTk.PhotoImage(eim) rightImage['image'] = rphoto rphoto.image = rphoto print(len(raw)) if extractContentType.get() == "Plain text": extractStatusLbl.configure(text="Success") outputTexArea.delete('1.0',"end") outputTexArea.insert('1.0', raw) elif extractContentType.get() == "File": with open(extractToFilename, "wb") as target: target.write(raw) print(f"Succecfully extracted to: {extractToFilename}") else: raise AssertionError("Invalid extract content type")
def test_plain_text(): print('test_plain_text()') in_img = "test_imgs/mountain.png" msg = b"This is my secret" out_img = "mountain_DCT.png" en = DCT(in_img) en.DCTEn(msg, out_img) dec = DCT(out_img) secret = dec.DCTDe() if secret != msg: raise AssertionError("Secret != msg") print('Passed!\n')
def test_embed_img(): print("test_embed_img()") in_img = "test_imgs/river.png" with open("test_imgs/face.jpg", "rb") as f: raw = f.read() out_img = "river_DCT.png" en = DCT(in_img) en.DCTEn(raw, out_img) dec = DCT(out_img) secret = dec.DCTDe() if secret != raw: raise AssertionError("Secret face.jpg != original face.jpg") print('Passed!\n')
from dct import DCT in_img = "test_imgs/mountain.png" msg = b"This is my secret" out_img = "mountain_dct.png" en = DCT(in_img) en.DCTEn(msg, out_img) dec = DCT(out_img) secret = dec.DCTDe().decode() print(secret)