zxcvbn-ts / zxcvbn

Low-Budget Password Strength Estimation
https://www.usenix.org/conference/usenixsecurity16/technical-sessions/presentation/wheeler
MIT License
858 stars 68 forks source link

Consider adding base to output #223

Closed sunknudsen closed 2 months ago

sunknudsen commented 1 year ago

Trying to translate crackTimesDisplay values using translations implemented using i18next and react-i18next to consolidate translations in one place rather than depending on language packages.

Problem is base is not included in output so it appears one has to compute this ourselves.

Perhaps I am missing something… this project is amazing btw!

{
  "ltSecond": "less than a second",
  "second": "{base} second",
  "seconds": "{base} seconds",
  "minute": "{base} minute",
  "minutes": "{base} minutes",
  "hour": "{base} hour",
  "hours": "{base} hours",
  "day": "{base} day",
  "days": "{base} days",
  "month": "{base} month",
  "months": "{base} months",
  "year": "{base} year",
  "years": "{base} years",
  "centuries": "centuries"
}
MrWook commented 1 year ago

Hey thanks for the issue. I will look into it if i can get the base value into the output. In the meantime you could add your translations into zxcvbn-ts dependent on your setup. For example if you have a typescript file with all translations in it:

import { zxcvbn, zxcvbnOptions } from '@zxcvbn-ts/core'
import translations from './yourTranslations'

const password = 'somePassword'
const options = {
  translations: translations.crackTimeDisplay,
}

zxcvbnOptions.setOptions(options)

zxcvbn(password)