Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for alphanumeric/simple password generation #24

Open
alex0112 opened this issue Mar 10, 2022 · 2 comments
Open

Add support for alphanumeric/simple password generation #24

alex0112 opened this issue Mar 10, 2022 · 2 comments

Comments

@alex0112
Copy link
Contributor

alex0112 commented Mar 10, 2022

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}$
@alex0112
Copy link
Contributor Author

alex0112 commented Mar 10, 2022

I've been thinking about this feature for a hot minute. Happy to implement it if there's interest and no one else beats me to it.

@alex0112 alex0112 changed the title Add support for alphanumeric/or simple password generation Add support for alphanumeric/simple password generation Mar 10, 2022
@alex0112
Copy link
Contributor Author

If there's interest in this feature, I'd also like to add another option (which I will write up in a separate issue) that's something like --exclude-strange which would simply exclude some of the commonly disallowed characters mentioned above.

My thought being that when a site disallowing the regular character set is hit, a user can:

  • First try excluding quotes, backticks, backslashes etc. with --exclude-strange
  • If that's not successful, try using only the slightly less complex charpool with --simple, and if that one is rejected
  • Default to --alphanumeric and weep salty tears at the state of password policies on whatever service they are using.

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

No branches or pull requests

1 participant