Skip to content

Instantly share code, notes, and snippets.

@moe-rika
Created September 18, 2022 10:05
Show Gist options
  • Select an option

  • Save moe-rika/ee9004792a30da76c104fb32ccd6fd02 to your computer and use it in GitHub Desktop.

Select an option

Save moe-rika/ee9004792a30da76c104fb32ccd6fd02 to your computer and use it in GitHub Desktop.
import numpy as np
from blind_watermark import WaterMark
from reedsolo import RSCodec
rsc = RSCodec(128)
# 1057226 - 1024 * 1032 = 458
with open("a.docx", "rb") as f:
data = f.read()
print(len(data))
i = 0
while (True):
if i == 1033:
break
bwm1 = WaterMark(password_img=1, password_wm=1)
bwm1.read_img('6b7858c3798b5d0d1afb9f67bf43e2d5.jpg')
kk = rsc.encode(data[i * 1024:i * 1024 + 1024])
if i == 1032:
kk = rsc.encode(data[i * 1024:i * 1024 + 458])
byte = bin(int(kk.hex(), base=16))
wm = np.array(list(byte)) == '1'
bwm1.read_wm(wm, mode='bit')
bwm1.embed('embedded-{}.jpg'.format(i))
len_wm = len(bwm1.wm_bit)
print({i: len_wm})
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment