~gagbo/diceware.py

2cd106dadca83c7538e5e439f218174cc8387691 — Gerry Agbobada 2 years ago 3220fc4
Clean up interface in front-facing executable

Signed-off-by: Gerry Agbobada <gagbobada+git@gmail.com>
1 files changed, 11 insertions(+), 9 deletions(-)

M diceware.py
M diceware.py => diceware.py +11 -9
@@ 23,32 23,34 @@ def print_entropy_help(fileDesc):
    )


def create_passphrase(**kwargs):
    """ Create a passphrase using forwarded kwargs arguments to Diceware simulator."""
    result = dw.DicewareResult(**kwargs)
    result.make_rolls()
    return result


if __name__ == "__main__":
    print_entropy_help(sys.stdout)
    with open("data/diceware-fr-5-jets.txt", "r") as fr:
        diceware_dict = list_to_dict.create_dictionary(fr)

    print("Default :")
    test_value = dw.DicewareResult()
    test_value.make_rolls()
    test_value = create_passphrase()
    print(test_value)
    print(test_value.password_from_dict(diceware_dict))

    print("\nOnly 2 words :")
    test_value_2 = dw.DicewareResult(wordsCount=2)
    test_value_2.make_rolls()
    test_value_2 = create_passphrase(wordsCount=2)
    print(test_value_2)
    print(test_value_2.password_from_dict(diceware_dict))

    print("\nNo salt :")
    test_value_3 = dw.DicewareResult(bonusRoll=False)
    test_value_3.make_rolls()
    test_value_3 = create_passphrase(bonusRoll=False)
    print(test_value_3)
    print(test_value_3.password_from_dict(diceware_dict))

    print("\nPseudo random - No Salt - 3 words :")
    test_value_4 = dw.DicewareResult(
        wordsCount=3, systemRand=False, bonusRoll=False)
    test_value_4.make_rolls()
    test_value_4 = create_passphrase(wordsCount=3, systemRand=False, bonusRoll=False)
    print(test_value_4)
    print(test_value_4.password_from_dict(diceware_dict))