def sampled_entropy(sample_size, success_size):
'''
Estimate the change in entropy given a sample of passwords from a set.
Rationalle: Assume that we can produce passwords with a known entropy.
However, not all of these passwords are at least 24 characters long. Rather
than try to calculate the exact change in entropy, we estimate it by
generating {sample_size} passwords, and seeing that {success_size} meet our
constraints. We then assume that the ratio of these numbers is proportional
to the overall ratio of possible_passwords to allowed_passwords. This
allows us to do the following caluclation:
original_entropy = log2(permutation_space)
new_entropy = log2(permutation_space * ratio)
= log2(permutation_space) + log2(ratio)
= log2(permutation_space) + log2(success_size / sample_size)
= log2(permutation_space) + log2(success_size) - log2(sample_size)
= original_entropy + log2(success_size) - log2(sample_size)
'''
return log2(success_size) - log2(sample_size)
评论列表
文章目录