Skip to content

Conversation

@segiddins
Copy link
Contributor

This adds an optional buffer argument to the Cipher#final method, matching the behavior of Cipher#update. When a buffer is provided, the output is written to it and the same buffer object is returned. Otherwise, a new string is created and returned.

The implementation follows the same pattern as update:

  • Accepts an optional string buffer parameter
  • Reuses the buffer if provided, creating a new string if not
  • Automatically resizes the buffer as needed
  • Forces ASCII-8BIT encoding for binary cipher output
  • Raises FrozenError if the buffer is frozen

This adds an optional buffer argument to the Cipher#final method,
matching the behavior of Cipher#update. When a buffer is provided,
the output is written to it and the same buffer object is returned.
Otherwise, a new string is created and returned.

The implementation follows the same pattern as update:
- Accepts an optional string buffer parameter
- Reuses the buffer if provided, creating a new string if not
- Automatically resizes the buffer as needed
- Forces ASCII-8BIT encoding for binary cipher output
- Raises FrozenError if the buffer is frozen
@rhenium
Copy link
Member

rhenium commented Dec 26, 2025

Why is this needed or desirable?

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