# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/00-core.ipynb (unless otherwise specified).

__all__ = ['encode', 'decode']

# Cell
from loguru import logger
import sys

logger.remove()
logger.add(sink=sys.stderr, level='INFO')

# Cell
import cryptocode
import base64

# Cell
def encode(message, key='BiWQSQyKTBRPhrmKEUVTfsEhckjVUuZe6rMHqLQSa2JbrRcQCk'):
    ciphertext = cryptocode.encrypt(message, key)
    encoded_ciphertext = base64.b64encode(ciphertext.encode('utf-8'))
    str_encoded = ''.join(chr(b) for b in encoded_ciphertext if chr(b).isalnum())
    return str_encoded

# Cell
def decode(str_encoded, key='BiWQSQyKTBRPhrmKEUVTfsEhckjVUuZe6rMHqLQSa2JbrRcQCk'):
    decoded_ciphertext = base64.b64decode(str_encoded.encode('utf-8'))
    str_decoded = cryptocode.decrypt(decoded_ciphertext.decode('utf-8'), key)
    return str_decoded