Last active
September 11, 2021 08:12
-
-
Save lorenzobn/dca3aaef341965c32d207ee6d23185ee to your computer and use it in GitHub Desktop.
Snippet taken from main.py with a focus on LSB retrieving function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while (end == False): | |
while (bit_i >= 0): | |
px = matrix[start_pixel] | |
# colors: Red, Green and Blue | |
for c in range(conf[0], conf[1]): | |
if bit_i >= 0: | |
# We are getting the LSB of the pixel color, and then we shift it to the left accordingly | |
byte += (px[c]&1)<<bit_i | |
bit_i -= 1 | |
else: | |
break | |
start_pixel = get_num_rand(used_pixels, num_of_pixels) | |
if start_pixel>=num_of_pixels: | |
break | |
# decoded 1 byte | |
message += chr(byte) | |
# have I encountered the eof_marker? If yes, the decoding process is done | |
if message[-len(EOF_MARKER):] == EOF_MARKER: | |
end = True | |
byte = 0 | |
bit_i = 7 | |
start_pixel = get_num_rand(used_pixels, num_of_pixels) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment