from importlib.metadata import version
from packaging.version import Version

__project_name__ = "steggynography"

verbose_ver = Version(version(__project_name__))
__version__ = [verbose_ver.major, verbose_ver.minor, verbose_ver.micro]

# binary operations
def dec_to_bin(dec : int, bit_dep : int):
  return [(dec >> i) & 1 for i in range((bit_dep - 1), -1, -1)]

def bin_to_dec(bin : list[int]) -> int:
  dec = 0
  for bit in bin:
    dec = (dec << 1) | bit

  return dec

def bin_to_ascii(bin : list[int]) -> str:
  decs = [bin_to_dec(bin[i:i + 8]) for i in range(0, len(bin), 8)]
  return "".join(chr(dec) for dec in decs)

