mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 17:18:30 +02:00
17 lines
No EOL
394 B
Python
17 lines
No EOL
394 B
Python
#! /usr/local/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
def a2bits(chars):
|
|
"""
|
|
Convert a string to its bits representation as a string of 0's and 1's.
|
|
"""
|
|
return bin(reduce(lambda x, y : (x<<8)+y, (ord(c) for c in chars), 1))[3:]
|
|
|
|
def bs(s):
|
|
"""
|
|
Convert a int to its bits representation as a string of 0's and 1's.
|
|
"""
|
|
return str(s) if s<=1 else bs(s>>1) + str(s&1) |