Repository navigation
fix(ess-passwords): count entropy without replacement - #141
Merged
Merged
Conversation
Words are drawn without replacement, so entropy is now the sum of log2(N - i) per draw. A word count above the filtered wordlist raises PasswordPolicyError, and a max_length too small for the word count raises the new PasswordLengthError. Document that entropy is an upper bound under max_length and that --json omits the stderr note.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
word_count * log2(N).PasswordPolicyErrorwhenword_countexceeds the filtered wordlist, instead of letting xkcdpass raiseValueError.PasswordLengthError, aPasswordPolicyErrorsubclass, for amax_lengthtoo small for the word count. It is exported from the package.entropy_bitsis an upper bound whenmax_lengthis set, and that--jsoncarries entropy in the payload and skips the stderr note.Test plan
uv run pytest packages/python/ess-passwords(37 passed), including new tests for entropy without replacement, the word-count limit, and the--jsonstderr behaviour.