mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-06-28 03:06:14 +02:00
Management of unicode. It would be perfect to manage ASCII and unicode in the same time (so 8 bits to 32 bits caracters).
This commit is contained in:
parent
e803386361
commit
6ad140bdfb
4 changed files with 12 additions and 11 deletions
|
@ -106,9 +106,9 @@ def reveal(input_image_file):
|
|||
if img.mode == 'RGBA':
|
||||
pixel = pixel[:3] # ignore the alpha
|
||||
for color in pixel:
|
||||
buff += (color&1)<<(7-count)
|
||||
buff += (color&1)<<(31-count)
|
||||
count += 1
|
||||
if count == 8:
|
||||
if count == 32:
|
||||
bitab.append(chr(buff))
|
||||
buff, count = 0, 0
|
||||
if bitab[-1] == ":" and limit == None:
|
||||
|
|
|
@ -104,9 +104,9 @@ def reveal(input_image_file, generator):
|
|||
generated_number = next(generator)
|
||||
# color = [r, g, b]
|
||||
for color in img_list[generated_number]:
|
||||
buff += (color&1)<<(7-count)
|
||||
buff += (color&1)<<(31-count)
|
||||
count += 1
|
||||
if count == 8:
|
||||
if count == 32:
|
||||
bitab.append(chr(buff))
|
||||
buff, count = 0, 0
|
||||
if bitab[-1] == ":" and limit == None:
|
||||
|
|
|
@ -57,7 +57,8 @@ def a2bits_list(chars: str) -> List[str]:
|
|||
>>> "".join(a2bits_list("Hello World!"))
|
||||
'010010000110010101101100011011000110111100100000010101110110111101110010011011000110010000100001'
|
||||
"""
|
||||
return [bin(ord(x))[2:].rjust(8,"0") for x in chars]
|
||||
#return [bin(ord(x))[2:].rjust(8,"0") for x in chars]
|
||||
return [bin(ord(x))[2:].rjust(32,"0") for x in chars]
|
||||
|
||||
def bs(s: int) -> str:
|
||||
"""Converts an int to its bits representation as a string of 0's and 1's.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue