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

Method extract_data

StegaPy/StegaPy.py:89–124  ·  view source on GitHub ↗

从隐写后的图像数据中提取并还原隐藏的机密信息。

(self, stego_data: bytes, 
                    stego_filename: Optional[str])

Source from the content-addressed store, hash-verified

87 raise StegaPyException(str(e), StegaPyErrors.UNHANDLED_EXCEPTION, self.NAMESPACE)
88
89 def extract_data(self, stego_data: bytes,
90 stego_filename: Optional[str]) -> List:
91 """从隐写后的图像数据中提取并还原隐藏的机密信息。"""
92 if Purpose.DATA_HIDING not in self.plugin.get_purposes():
93 raise StegaPyException(
94 "插件不支持数据隐藏",
95 StegaPyErrors.PLUGIN_DOES_NOT_SUPPORT_DH,
96 self.NAMESPACE
97 )
98
99 try:
100 # 提取数据
101 msg_filename = self.plugin.extract_msg_filename(stego_data, stego_filename)
102 msg = self.plugin.extract_data(stego_data, stego_filename, None)
103
104 # 解密数据(如果启用)
105 if self.config.is_use_encryption():
106 if not self.config.get_password():
107 raise StegaPyException(
108 "解密需要密码",
109 StegaPyErrors.INVALID_PASSWORD,
110 self.NAMESPACE
111 )
112 crypto = CryptoUtil(self.config.get_password(),
113 self.config.get_encryption_algorithm())
114 msg = crypto.decrypt(msg)
115
116 # 解压数据(如果启用)
117 if self.config.is_use_compression():
118 msg = self._decompress_data(msg)
119
120 return [msg_filename, msg]
121 except StegaPyException:
122 raise
123 except Exception as e:
124 raise StegaPyException(str(e), StegaPyErrors.UNHANDLED_EXCEPTION, self.NAMESPACE)
125
126 def embed_mark(self, sig: bytes, sig_filename: Optional[str],
127 cover: Optional[bytes], cover_filename: Optional[str],

Callers 7

cmd_extractFunction · 0.95
data_hiding_uiFunction · 0.95
test_roundtrip_basicMethod · 0.45
test_roundtripMethod · 0.45

Calls 10

decryptMethod · 0.95
_decompress_dataMethod · 0.95
StegaPyExceptionClass · 0.85
CryptoUtilClass · 0.85
is_use_encryptionMethod · 0.80
get_passwordMethod · 0.80
is_use_compressionMethod · 0.80
get_purposesMethod · 0.45
extract_msg_filenameMethod · 0.45

Tested by 5

test_roundtrip_basicMethod · 0.36
test_roundtripMethod · 0.36