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

Function extract_data

StegaPy/util/string_util.py:47–82  ·  view source on GitHub ↗

从隐写数据中提取消息

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

Source from the content-addressed store, hash-verified

45 return gzip.compress(data)
46
47 def extract_data(self, stego_data: bytes,
48 stego_filename: Optional[str]) -> List:
49 """从隐写数据中提取消息"""
50 if Purpose.DATA_HIDING not in self.plugin.get_purposes():
51 raise StegaPyException(
52 "插件不支持数据隐藏",
53 StegaPyErrors.PLUGIN_DOES_NOT_SUPPORT_DH,
54 self.NAMESPACE
55 )
56
57 try:
58 # 提取数据
59 msg_filename = self.plugin.extract_msg_filename(stego_data, stego_filename)
60 msg = self.plugin.extract_data(stego_data, stego_filename, None)
61
62 # 解密数据(如果启用)
63 if self.config.is_use_encryption():
64 if not self.config.get_password():
65 raise StegaPyException(
66 "解密需要密码",
67 StegaPyErrors.INVALID_PASSWORD,
68 self.NAMESPACE
69 )
70 crypto = CryptoUtil(self.config.get_password(),
71 self.config.get_encryption_algorithm())
72 msg = crypto.decrypt(msg)
73
74 # 解压数据(如果启用)
75 if self.config.is_use_compression():
76 msg = self._decompress_data(msg)
77
78 return [msg_filename, msg]
79 except StegaPyException:
80 raise
81 except Exception as e:
82 raise StegaPyException(str(e), StegaPyErrors.UNHANDLED_EXCEPTION, self.NAMESPACE)
83

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