MCPcopy Create free account
hub / github.com/MearaY/StegaPy / TestRandomLSB

Class TestRandomLSB

tests/test_e2e.py:97–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95
96
97class TestRandomLSB:
98 def _sp(self, **kwargs):
99 from StegaPy.plugin.randlsb import RandomLSBPlugin
100 from StegaPy.plugin.lsb.lsb_config import LSBConfig
101 cfg = LSBConfig(**kwargs)
102 p = RandomLSBPlugin(); p.config = cfg
103 return _make_stegapy(p, cfg)
104
105 def test_roundtrip(self):
106 cover = _cover_bytes(512, 512)
107 msg = MSG_LONG.read_bytes()
108 sp = self._sp(use_compression=False)
109 stego = sp.embed_data(msg, "msg.txt", cover, "cover.png", "stego.png")
110 _, out = sp.extract_data(stego, "stego.png")
111 assert out == msg
112
113 def test_different_from_lsb(self):
114 """RandomLSB 与 LSB 嵌入结果应不同(随机性验证)"""
115 from StegaPy.plugin.lsb import LSBPlugin
116 from StegaPy.plugin.lsb.lsb_config import LSBConfig
117 cover = _cover_bytes(256, 256)
118 msg = b"test difference"
119 cfg = LSBConfig(use_compression=False)
120
121 p_lsb = LSBPlugin(); p_lsb.config = cfg
122 stego_lsb = _make_stegapy(p_lsb, cfg).embed_data(msg, "m.txt", cover, "c.png", "s.png")
123
124 sp_r = self._sp(use_compression=False)
125 stego_r = sp_r.embed_data(msg, "m.txt", cover, "c.png", "s.png")
126
127 assert stego_lsb != stego_r
128
129
130class TestDWTWatermark:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected