Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/zxcvbn/matchers/date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def extract_dates(token)
:day => ''
}
for i in 0...token.length
candidate[PATTERN_CHAR_TO_SYM[pattern[i]]] << token[i]
key = PATTERN_CHAR_TO_SYM[pattern[i]]
candidate[key] = +(candidate[key] || String.new)
candidate[key] << token[i]
end
candidate.each do |component, value|
candidate[component] = value.to_i
Expand Down
14 changes: 7 additions & 7 deletions spec/scoring/entropy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def data
let(:token) { '23456' }

it 'returns the correct value' do
expect(entropy.sequence_entropy(match)).to eq 5.643856189774725
expect(entropy.sequence_entropy(match)).to be_within(1e-12).of(5.643856189774725)
end
end

Expand Down Expand Up @@ -69,7 +69,7 @@ def data
describe '#digits_entropy' do
it 'returns the correct value' do
match = Zxcvbn::Match.new(:token => '12345678')
expect(entropy.digits_entropy(match)).to eq 26.5754247590989
expect(entropy.digits_entropy(match)).to be_within(1e-12).of(26.5754247590989)
end
end

Expand Down Expand Up @@ -183,23 +183,23 @@ def data
it 'should return the correct entropy' do
match.graph = 'keypad'

expect(entropy.spatial_entropy(match)).to eql 9.05528243550119
expect(entropy.spatial_entropy(match)).to be_within(1e-12).of(9.05528243550119)
end
end

context 'when match includes several turns' do
it 'should return the correct entropy' do
match.turns = 5

expect(entropy.spatial_entropy(match)).to eql 21.761397858718993
expect(entropy.spatial_entropy(match)).to be_within(1e-12).of(21.761397858718993)
end
end

context 'when match includes shifted count' do
it 'should return the correct entropy' do
match.shiffted_count = 5

expect(entropy.spatial_entropy(match)).to eql 9.05528243550119
expect(entropy.spatial_entropy(match)).to be_within(1e-12).of(9.05528243550119)
end
end

Expand All @@ -208,9 +208,9 @@ def data
match.shiffted_count = 5
match.turns = 5

expect(entropy.spatial_entropy(match)).to eql 21.761397858718993
expect(entropy.spatial_entropy(match)).to be_within(1e-12).of(21.761397858718993)
end
end
end

end
end