Skip to content

Lib/bytes password#2344

Merged
ChanTsune merged 2 commits into
mainfrom
lib/bytes-password
Nov 21, 2025
Merged

Lib/bytes password#2344
ChanTsune merged 2 commits into
mainfrom
lib/bytes-password

Conversation

@ChanTsune

Copy link
Copy Markdown
Owner

No description provided.

Change password APIs to accept byte slices instead of strings only,
  enabling use of binary keys and non-UTF-8 encoded passwords.

  Changes:
  - Password internal type: String → Vec<u8>
  - Public API generic bounds: AsRef<str> → AsRef<[u8]>
  - Write path (builders): Fully backward compatible
  - Read path (direct params): Breaking - requires .as_bytes() or b"" prefix

  Breaking changes:
  - Archive::entries_with_password(password: &str) → password: &[u8]
  - Entries::extract_solid_entries(password: &str) → password: &[u8]
  - SolidEntry::entries(password: &str) → password: &[u8]

  Migration:
    // Before
    archive.entries_with_password(Some("password"))

    // After
    archive.entries_with_password(Some(b"password"))

  Builder APIs remain fully compatible:
    WriteOptions::builder().password(Some("password"))  // Still works
    WriteOptions::builder().password(Some(b"key"))      // Now works
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ChanTsune, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the password handling mechanism throughout the codebase, transitioning from string-based passwords to byte-slice-based passwords. This change enhances the robustness and security of password management by accommodating non-UTF8 characters and providing a more direct representation of raw password data. The update impacts both the command-line interface and the core library, requiring adjustments to function signatures, data structures, and test utilities to align with the new byte-oriented approach.

Highlights

  • Password Type Change: The internal representation and API for passwords have been updated from String or &str to Vec<u8> or &[u8], allowing for non-UTF8 compliant passwords and improved security.
  • API Modernization: Various functions and traits across the cli and lib crates, including ask_password, check_password, entry_option, TransformStrategy, extract_entry, and run_list_archive, have been updated to reflect the new byte-slice password type.
  • Enhanced Password Handling: The Password struct now stores passwords as Vec<u8>, and WriteOptionsBuilder and ReadOptions methods for setting passwords now accept any type that can be converted to &[u8], providing more flexibility.
  • Test Updates: All relevant test cases have been modified to use byte literals (e.g., b"password") when providing passwords, ensuring compatibility with the new byte-based password handling.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request correctly refactors password handling from String to Vec<u8> across the library and CLI. This is an important improvement for both security and correctness, as it allows passwords to contain arbitrary bytes, not just valid UTF-8. The changes are consistent and well-implemented, including the use of generics to make the password-setting APIs more flexible. I've suggested one minor refactoring to improve code clarity in cli/src/command.rs, but overall this is a solid contribution.

Comment thread cli/src/command.rs
@github-actions github-actions Bot added cli This issue is about cli application lib This issue is about lib crate break API braking change labels Nov 14, 2025
@ChanTsune
ChanTsune merged commit 7208008 into main Nov 21, 2025
99 checks passed
@ChanTsune
ChanTsune deleted the lib/bytes-password branch November 21, 2025 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

break API braking change cli This issue is about cli application lib This issue is about lib crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant