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')
def embedImage(): algo = variable.get() inp = getSecretContent() out_f, out_ext = embedInputFile.split(".") out_f = out_f + "_" + algo + ".png" fileName = os.path.basename(out_f) fileName = outFolder + "/" + fileName if(algo == "LSB"): lsb.encodeImage(embedInputFile, inp, fileName) elif(algo == "Blowfish"): #encrypt the input data inp = blowfish_algo.encrypt(inp) print(type(inp)) lsb.encodeImage(embedInputFile, inp, fileName) elif(algo == "BPCS"): global alpha bpcs.encode(embedInputFile, inp, fileName, alpha) elif(algo == "DCT"): d = DCT(embedInputFile) d.DCTEn(inp, fileName) lim=Image.open(embedInputFile) lim = lim.resize((100, 75), Image.ANTIALIAS) lphoto=ImageTk.PhotoImage(lim) inImage['image'] = lphoto lphoto.image = lphoto oim=Image.open(embedInputFile) oim = oim.resize((100, 75), Image.ANTIALIAS) ophoto=ImageTk.PhotoImage(oim) emImage['image'] = ophoto ophoto.image = ophoto embedStatusLbl.configure(text="Success") print("Embed Success")
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)