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

Function extract_data

StegaPy/util/validation_util.py:15–50  ·  view source on GitHub ↗

从隐写数据中提取消息

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

Source from the content-addressed store, hash-verified

13
14
15 def extract_data(self, stego_data: bytes,
16 stego_filename: Optional[str]) -> List:
17 """从隐写数据中提取消息"""
18 if Purpose.DATA_HIDING not in self.plugin.get_purposes():
19 raise StegaPyException(
20 "插件不支持数据隐藏",
21 StegaPyErrors.PLUGIN_DOES_NOT_SUPPORT_DH,
22 self.NAMESPACE
23 )
24
25 try:
26 # 提取数据
27 msg_filename = self.plugin.extract_msg_filename(stego_data, stego_filename)
28 msg = self.plugin.extract_data(stego_data, stego_filename, None)
29
30 # 解密数据(如果启用)
31 if self.config.is_use_encryption():
32 if not self.config.get_password():
33 raise StegaPyException(
34 "解密需要密码",
35 StegaPyErrors.INVALID_PASSWORD,
36 self.NAMESPACE
37 )
38 crypto = CryptoUtil(self.config.get_password(),
39 self.config.get_encryption_algorithm())
40 msg = crypto.decrypt(msg)
41
42 # 解压数据(如果启用)
43 if self.config.is_use_compression():
44 msg = self._decompress_data(msg)
45
46 return [msg_filename, msg]
47 except StegaPyException:
48 raise
49 except Exception as e:
50 raise StegaPyException(str(e), StegaPyErrors.UNHANDLED_EXCEPTION, self.NAMESPACE)
51
52
53

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected