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

Passwords are sometimes the wrong length #76

Closed
alexandervandekleutab opened this issue Jun 29, 2022 · 2 comments
Closed

Passwords are sometimes the wrong length #76

alexandervandekleutab opened this issue Jun 29, 2022 · 2 comments

Comments

@alexandervandekleutab
Copy link

The following will sometimes generate passwords of length 7 containing no special characters:

passwordGenerator.generate({
      length: 8,
      strict: true,
      numbers: true,
      lowercase: true,
      uppercase: true,
      symbols: true,
      // These exclusions are either reserved(before space)
      // or unsafe(including and after space) characters for URLs
      exclude: '&$+,/:;=?@# <>[]{}|^%',
    })

We are passing this password to a callback that generates emails by directly injecting the password into a URL. Therefore we cannot pass symbols usually reserved for URLs. This code generated the password ADd9xFM which is 7 characters long.

@brendanashworth
Copy link
Owner

@alexandervandekleutab not convinced this is an issue on our end. I can't seem to reproduce even with a lot of passwords:

> gen.generateMultiple(1000000, options).filter(s => s.length != 8)
[]

After stripping out the characters you exclude, encodeURI still gives different characters. Do you want to exclude those too?

> let symbols = '!@#$%^&*()+_-=}{[]|:;"/?.><,`~'
undefined
> let passthru = symbols.split('').filter(c => '&$+,/:;=?@# <>[]{}|^%'.indexOf(c) === -1)
undefined
> passthru
[
  '!', '*', '(', ')',
  '_', '-', '"', '.',
  '`', '~'
]
> passthru.map(c => encodeURI(c))
[
  '!',   '*', '(',
  ')',   '_', '-',
  '%22', '.', '%60',
  '~'
]

@brendanashworth
Copy link
Owner

Going to close this because it hasn't been reproduced.

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

2 participants