Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing function shouldn't contain UI calls #6

Open
dkushche opened this issue May 3, 2022 · 0 comments
Open

Processing function shouldn't contain UI calls #6

dkushche opened this issue May 3, 2022 · 0 comments
Assignees

Comments

@dkushche
Copy link
Owner

dkushche commented May 3, 2022

The processing function should be able to be used by other software. This software won't need to init interface which is part of crypto UI, so all cterm calls shouldn't be in the processing function.

Example:

def cryptoapi_aes_processing(data, key_length, key,
                            mode, provider, encrypt):

    if platform.system() != "Windows":
        return f"Unsupported on your platform {platform.system()}"

    cryptoapi_aes_pre_processing(key, key_length)

    if provider == "standard":
        result = crypto_native.ms_cryptoapi_standard_aes(
            data, key, encrypt
        )
    else:
        result = crypto_native.ms_cryptoapi_nextgen_aes(
            data, key, mode, encrypt
        )

    crypto_tools.cterm("output", f"Hashed key: {result['hashed_key']}", "inf")
    crypto_tools.cterm("output", f"Session key: {result['session_key']}", "inf")

    return result["result"]

If I try to import cryptoapy_aes and call just its processor I will get an Exception because the color palette for cterm is not defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants