def encrypt()

in modules/crypto.py [0:0]


def encrypt(source_file: str, target_file="", overwrite=False) -> str:
    """Encrypt an existing file, place in data/secrets"""
    if not target_file:
        target_file = os.path.splitext(source_file)[0]
    if not source_file.endswith(".json"):
        raise OSError("We only encrypt json files")
    target_loc = os.path.join("data", "secrets", f"{target_file}.json")
    if os.path.exists(target_loc) and not overwrite:
        raise OSError("Cannot overwrite existing file, set overwrite=True to ignore.")

    with open(source_file) as fh:
        secret = json.load(fh)
    token = encrypt_ends(secret)

    with open(target_loc, "w") as fh:
        json.dump(token, fh, indent=2)

    return target_loc