Skip to content

Add support for alphanumeric/simple password generationย #24

@alex0112

Description

@alex0112

Problem

I often find myself needing to generate a password where characters such as ' " \ or a backtick are not allowed.

A while back the --exclude flag was added in #23, but I often find myself hitting this scenario:

$ pws gen example-passwd --exclude '\\`\'"'
dquote>

Usually I'm too lazy to figure out the proper quoting conventions for these characters in my current shell, and often my workflow for sites that block characters like these is to do this:

pws gen example-passwd --charpool 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()_-+='

Which works, but is a bit much in terms of manual typing.
Even then, sometimes sites will reject some of those characters. So I end up defaulting to:

pws gen example-passwd --charpool 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'

Proposed Solution:

Add two new options:

  • --alphanumeric to generate a password only matching the character class [A-Za0-9a-z]
  • --simple to generate a password only matching the character class [0-9a-zA-Z!@#$%^&*()]

I've taken the liberty of prototyping a few Gherkin tests about what the end behavior might look like:

Scenario: Generate a new password for "github", using only alphanumeric characters
    Given A safe exists with master password "my_master_password"
    When I run `pws generate github 0 --alphanumeric` interactively
    And I type "my_master_password"
    Then the output should contain "Master password:"
    And the output should contain "The password for github has been added"
    And  the output should contain "The password for github has been copied to your clipboard"
    And  the clipboard should match ^[0-9a-zA-Z]{64}$
Scenario: Generate a new password for "github", using only alphanumeric and no special characters
    Given A safe exists with master password "my_master_password"
    When I run `pws generate github 0 --basic` interactively
    And I type "my_master_password"
    Then the output should contain "Master password:"
    And the output should contain "The password for github has been added"
    And  the output should contain "The password for github has been copied to your clipboard"
    And  the clipboard should match ^[0-9a-zA-Z!@#$%^&*()]{64}$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions