Skip to content

Refactoring BasicXorEncryptor to make more readable.#228

Merged
avalerio-tkd merged 5 commits into
mainfrom
av_typelist_optimizing_073
Mar 10, 2026
Merged

Refactoring BasicXorEncryptor to make more readable.#228
avalerio-tkd merged 5 commits into
mainfrom
av_typelist_optimizing_073

Conversation

@avalerio-tkd

Copy link
Copy Markdown
Collaborator
  • Making BasicXorEncryptor more readable.
  • Adding internal documentation and comments for guidance to future implementations.
  • Adding a PrintableTypedValuesBuffer function to the TypedValuesBuffer class for debugging.

- Adding internal documentation and comments for guidance to future implementations.
- Adding a PrintableTypedValuesBuffer function to the TypedValuesBuffer class for debugging.

@argmarco-tkd argmarco-tkd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thank you! (left a minor comment around clarity in a comment. no need for a new PR).

Comment on lines +74 to +88
// NOTE ON TYPE-SPECIFIC ENCRYPTION:
//
// The current implementation encrypts each element by interpreting the elements a plain bytes,
// not utilizing the specific type of the buffer elements (INT32, INT64, etc.).
//
// A more sophisticated implementation could take advantage of the specific element type
// to call type-specific encryption functions, if the underlying library supports them.
//
// For example, a type-specific encryption per element could look like:
// size_t i = 0;
// for (const int32_t element : input_buffer) { // e.g. int32_t for TypedBufferI32
// auto encrypted = library.EncryptInt32(element, key_id);
// output_buffer.SetElement(i++, encrypted);
// }
//

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment may be confusing (because the code is in fact aware of types - just that we're not using them at encryption time.

I recommend modifying the first paragraph of the comment to

While the `EncryptValueList` method is aware of types, this encryptor implementation currently ignores the type.  It encrypts each element by interpreting the elements a plain bytes,
// not utilizing the specific type of the buffer elements (INT32, INT64, etc.).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks.

@avalerio-tkd avalerio-tkd merged commit 85114a6 into main Mar 10, 2026
2 checks passed
@avalerio-tkd avalerio-tkd deleted the av_typelist_optimizing_073 branch March 10, 2026 22:19
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

Successfully merging this pull request may close these issues.

2 participants