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

Method extract_data

StegaPy/plugin/randlsb/random_lsb_plugin.py:76–97  ·  view source on GitHub ↗

从隐写数据中提取消息

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

Source from the content-addressed store, hash-verified

74 raise StegaPyException(str(e), StegaPyErrors.UNHANDLED_EXCEPTION, self.NAMESPACE)
75
76 def extract_data(self, stego_data: bytes, stego_filename: Optional[str],
77 orig_sig_data: Optional[bytes] = None) -> bytes:
78 """从隐写数据中提取消息"""
79 try:
80 image = ImageUtil.byte_array_to_image(stego_data, stego_filename)
81 password = self.config.get_password() if self.config else None
82 lsb_is = RandomLSBInputStream(image, self.config, password)
83 header = lsb_is.get_data_header()
84 data = lsb_is.read(header.get_data_length())
85
86 if len(data) != header.get_data_length():
87 raise StegaPyException(
88 "数据读取不完整",
89 StegaPyErrors.ERR_IMAGE_DATA_READ,
90 self.NAMESPACE
91 )
92
93 return data
94 except StegaPyException:
95 raise
96 except Exception as e:
97 raise StegaPyException(str(e), StegaPyErrors.UNHANDLED_EXCEPTION, self.NAMESPACE)
98
99 def generate_signature(self) -> bytes:
100 """生成签名数据(RandomLSB不支持水印)"""

Callers

nothing calls this directly

Calls 7

get_data_headerMethod · 0.95
readMethod · 0.95
StegaPyExceptionClass · 0.85
byte_array_to_imageMethod · 0.80
get_passwordMethod · 0.80
get_data_lengthMethod · 0.80

Tested by

no test coverage detected