Skip to content

Processing function shouldn't contain UI calls #6

@dkushche

Description

@dkushche

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions