forked from deanishe/alfred-pwgen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify password strength in bits of entropy
- Loading branch information
Showing
7 changed files
with
143 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
# | ||
# Copyright © 2015 [email protected] | ||
# | ||
# MIT Licence. See https://opensource.org/licenses/MIT | ||
# | ||
# Created on 2015-07-28 | ||
# | ||
|
||
""" | ||
""" | ||
|
||
from __future__ import print_function, unicode_literals, absolute_import | ||
|
||
import os | ||
import sys | ||
|
||
# Guesses/second | ||
gps = 45000000000 | ||
|
||
bits = 32 | ||
|
||
|
||
def human_time(seconds): | ||
if seconds < 60: | ||
return '%0.3f seconds' % seconds | ||
minutes, seconds = divmod(seconds, 60) | ||
hours, minutes = divmod(minutes, 60) | ||
days, hours = divmod(hours, 24) | ||
weeks, days = divmod(days, 7) | ||
years, weeks = divmod(weeks, 52) | ||
centuries, years = divmod(years, 100) | ||
millenia, centuries = divmod(centuries, 10) | ||
universe_ages, millenia = divmod(millenia, 14000000) | ||
if universe_ages: | ||
return '%d ages of the universe' % universe_ages | ||
if millenia: | ||
return '%d millenia, %d centuries' % (millenia, centuries) | ||
if centuries: | ||
return '%d centuries, %d years' % (centuries, years) | ||
if years: | ||
return '%d years, %d weeks' % (years, weeks) | ||
elif weeks: | ||
return '%d weeks, %d days' % (weeks, days) | ||
|
||
while bits <= 256: | ||
# guesses = int('0b' + '1' * (bits - 1), 2) | ||
guesses = 2 ** (bits - 1) | ||
time = float(guesses) / gps | ||
print('%3d bits : %s' % (bits, human_time(time))) | ||
bits += 32 |