Skip to content

Instantly share code, notes, and snippets.

@padamupreti
Last active January 12, 2022 15:32
Show Gist options
  • Save padamupreti/0fa15180c32ddef70653abfe801ef708 to your computer and use it in GitHub Desktop.
Save padamupreti/0fa15180c32ddef70653abfe801ef708 to your computer and use it in GitHub Desktop.

Revisions

  1. padamupreti revised this gist Jan 12, 2022. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions psgen.py
    Original file line number Diff line number Diff line change
    @@ -9,11 +9,10 @@ def choose_specified(group, num=2):
    return ''.join(choice(group) for _ in range(num))

    def get_passphrase():
    keyphrase = ''
    char_groups = [ascii_lowercase, ascii_uppercase, punctuation, digits, ' ']
    keyphrase += ''.join(choice(''.join(char_groups)) for _ in range(9))
    length = len(char_groups)
    for _ in range(length):
    all_groups_str = ''.join(char_groups)
    keyphrase = ''.join(choice(all_groups_str) for _ in range(9))
    for _ in range(len(char_groups)):
    index = randbelow(len(char_groups))
    keyphrase += choose_specified(char_groups[index])
    del char_groups[index]
  2. padamupreti revised this gist Nov 27, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion psgen.py
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # strong passphrase generator and copier
    from secrets import choice, randbelow
    from string import ascii_lowercase, ascii_uppercase, punctuation, digits
    import pyperclip
    import pyperclip # pip install pyperclip

    def choose_specified(group, num=2):
    if len(group) == 1:
  3. padamupreti revised this gist Nov 11, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions psgen.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    # strong passphrase generator and copier
    from secrets import choice, randbelow
    from string import ascii_lowercase, ascii_uppercase, punctuation, digits
    import pyperclip
  4. padamupreti revised this gist Nov 9, 2021. No changes.
  5. padamupreti revised this gist Nov 9, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion psgen.py
    Original file line number Diff line number Diff line change
    @@ -18,4 +18,4 @@ def get_passphrase():
    del char_groups[index]
    return keyphrase

    pyperclip.copy(get_passphrase())
    pyperclip.copy(get_passphrase())
  6. padamupreti created this gist Nov 9, 2021.
    21 changes: 21 additions & 0 deletions psgen.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    from secrets import choice, randbelow
    from string import ascii_lowercase, ascii_uppercase, punctuation, digits
    import pyperclip

    def choose_specified(group, num=2):
    if len(group) == 1:
    return group
    return ''.join(choice(group) for _ in range(num))

    def get_passphrase():
    keyphrase = ''
    char_groups = [ascii_lowercase, ascii_uppercase, punctuation, digits, ' ']
    keyphrase += ''.join(choice(''.join(char_groups)) for _ in range(9))
    length = len(char_groups)
    for _ in range(length):
    index = randbelow(len(char_groups))
    keyphrase += choose_specified(char_groups[index])
    del char_groups[index]
    return keyphrase

    pyperclip.copy(get_passphrase())