Fixed Delimeter error for image steg

This commit is contained in:
devoalda 2023-05-23 11:21:45 +08:00
parent 5796b2b685
commit 82f0350af4
1 changed files with 6 additions and 5 deletions

View File

@ -64,12 +64,13 @@ class img_steg:
# Split by 8 bits # Split by 8 bits
all_bytes = [binary_data[i: i + 8] for i in range(0, len(binary_data), 8)] all_bytes = [binary_data[i: i + 8] for i in range(0, len(binary_data), 8)]
# Convert from bits to characters # Convert from bits to characters
decoded_data = self.from_bin(''.join(all_bytes)) decoded_data = ""
if decoded_data.endswith(self.delimiter): for byte in all_bytes:
decoded_data = decoded_data[:-4] decoded_data += chr(int(byte, 2))
if decoded_data[-len(self.delimiter):] == self.delimiter:
break
decoded_data = decoded_data.split(self.delimiter)[0] return decoded_data[:-len(self.delimiter)]
return decoded_data
def encode(self, secret_data: str = "Hello World") -> np.ndarray: def encode(self, secret_data: str = "Hello World") -> np.ndarray:
""" """