• Stars
    star
    290
  • Rank 142,981 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate passwords with Alfred

Alfred Password Generator

Generate secure random passwords from Alfred. Uses /dev/urandom as source of entropy.

Alfred Password Generator Demo

Features

  • Passwords can be generated based on strength or length.
  • Offers multiple generators, including based on real words and pronounceable pseudo-words generated with Markov chains.
  • Shows the strength of each generated password.
  • More convenient than 1Password or the like.
  • More dependable than online generators.
  • Copies passwords as "concealed" data by default (so clipboard managers don't record them).

Contents

Installation

Download from the GitHub releases or Packal and double-click the downloaded file to install.

Usage

  • pwgen [<strength>] β€” Generate passwords of specified strength. Default is 3 (96 bits of entropy). See Password strength for details.
    • ↩ β€” Copy the selected password to the clipboard.
    • βŒ˜β†© β€” Copy the selected password to the clipboard and paste it to the frontmost application.
    • βŒ₯↩ or ⌘C β€” Copy the selected password to the clipboard as public data
    • ^↩ β€” Copy the selected password to the clipboard as public data and paste it to the frontmost application.
    • ⌘+L β€” Show the selected password in Alfred's Large Text window.
  • pwlen [<length>] β€” Generate passwords of specified length. Default is 20. See Password strength for details.
    • ↩ β€” Copy the selected password to the clipboard.
    • βŒ˜β†© β€” Copy the selected password to the clipboard and paste it to the frontmost application.
    • βŒ₯↩ or ⌘C β€” Copy the selected password to the clipboard as public data
    • ^↩ β€” Copy the selected password to the clipboard as public data and paste it to the frontmost application.
    • ⌘+L β€” Show the selected password in Alfred's Large Text window.
  • pwconf [<query>] β€” View and edit workflow settings. See Configuration for details.

Note: Word-based generators may provide passwords that are slightly longer than <length>.

Password strength

Passwords can be specified either by strength or length. The default strength is 3, which is at least 96 bits of entropy (each level is 32 bits). You may also specify the desired number of bits by appending b to your input, e.g. pwgen 128b will provide at least 128 bits of entropy.

Default length is 20 characters, which can provide ~50 to ~130 bits of entropy depending on generator.

Each password has its strength in the result subtitle. This is shown either as a bar or in bits of entropy, depending on your settings. Each full block in the bar represents 32 bits of entropy. The icon shown next to each password also reflects its strength:

Icon Strength (bits of entropy)
Strength >= 96b
Strength > 64b and < 96b
Strength <= 64b

Entropy?

"Entropy" is cryptographese for "randomness".

How strong should my passwords be?

That depends on what you're using it for and how long you want it to remain secure. As of 2015, custom password-guessing hardware (built from standard PC components) can guess >45 billion passwords per second.

The average number of guesses required to crack a password with n bits of entropy is 2n-1, so 2,147,483,647 guesses for a 32-bit password. Or 0.048 seconds with the above hardware.

Fortunately, every added bit doubles the amount of entropy, so 64 bits is a good deal stronger: 6.5 years on average to guess on the same hardware.

Level Min. entropy Av. time to guessΒ * Application
1 32Β bits 0.048 seconds Stuff you want to be super easy to crack?
2 64Β bits 6.5 years Web accounts, WiFi passwords
3 96Β bits 280 million years Almost anything
4 128Β bits billions of times the age of the universe Toppest-secret stuff, e.g. encryption keysΒ **

* = based on 45 billion guesses per second. ** = symmetric encryption keys. SSL certificates, for example, use asymmetric keys, which offer much less security per bit. A 1024-bit RSA key has roughly equivalent security to an 80-bit symmetric key.

The default password strength level of 3 (96 bits) provides very secure passwords.

The default password length of 20 characters provides reasonably to very secure passwords, depending on the generator.

Displayed strength

By default, the strength of generated passwords is shown as a bar in the result subtitle. Each full block represents 32 bits of entropy, so 2 blocks represents a pretty secure password, 3 or more a very secure password.

You can have the precise number of bits displayed instead by toggling the "Strength Bar" setting in the Configuration (keyword pwconf).

How can passwords of the same length have different levels of security?

Passwords of the same length (or even the self-same password) generated using different techniques have different strengths because the strength is determined by the permutations in the algorithm and the password length, not the password itself.

For example, the single-digit password 1 has an entropy of 3.32 bits when generated by the Numeric algorithm because it is one of only 10 possible one-digit passwords. The same password generated by the ASCII algorithm has an entropy of 5.95 bits because it is one of 62 possible one-character passwords.

Of course, that's just in theory. A password generated by the German generator is theoretically more secure than the same password generated by the ASCII-only one because the former has more possible passwords of any given length. That only holds in practice if an attacker is also guessing passwords based on the German alphabet. If they're guessing based on ASCII, and the password only contains ASCII characters, the password is naturally as easily guessed as if it had been generated by the ASCII generator.

See Password strength on Wikipedia for more information.

Configuration

Access the configuration options with the pwconf keyword. You can use an optional query to filter the available options, e.g. use pwconf gen to show only the available generators.

The following configuraton options are available:

Open Help

Action this item to open this README in your browser.

An Update is Available / No Update is Available

The workflow checks for a new version once a day. If one is available, "An Update is Available" will be shown. Action this item to install the update.

If no update is available, "No Update is Available" will be shown. Action this item to force a check for an update.

Default Password Strength

The default strength for passwords generated with pwgen. For strength n, passwords will have n*32 bits of entropy. Default is 3, which should be proof against anything but the NSA. 4 will generate extremely secure passwords.

Action this item to enter a new default strength.

Default Password Length

The default length in characters for passwords generated with pwlen. The default of 20 provides passwords that are reasonably to very secure, depending on the generator.

Action this item to enter a new default length.

Strength Bar

By default, password strength is indicated by a number of blocks. Each full block represents 32 bits of entropy, so 3 blocks is secure, 4 is very secure. Less that 3 blocks should be avoided.

Alternatively, strength can be shown as the number of bits of entropy.

Action this item to toggle the strength bar on/off.

Generators

All the available generators are listed below the other options.

Active generators have a checked green circle as their icon, inactive ones have an empty red circle icon.

Action a generator to toggle it on or off.

Built-in generators

See below for details of how to add your own custom generators.

The workflow includes 10 built-in generators, of which 6 are active by default. You can activate/deactivate them in the Configuration.

Note: Word-based password generators return passwords with their component words joined by hyphens. These hyphens are not included in the calculation of the password strength, so removing them will leave you with a password of the stated strength.

Active generators

These generators are active by default.

ASCII Generator

Generates passwords based on all ASCII characters, minus a few punctuation marks that can be hard to type, such as \`~ (backslash, backtick, tilde).

Alphanumeric Generator

Generates passwords from ASCII letters and digits. No punctuation.

Clear Alphanumeric Generator

Generates passwords from ASCII letters and digits, excluding the easily-confused characters lO01 (lowercase L, uppercase O, the digits 1 and 0).

Numeric Generator

Generates digit-only passwords.

Pronounceable Nonsense Generator

Generates pronounceable passwords based on nonsense words. Based on this Stack Overflow answer.

Dictionary Generator

Generates passwords based on the words in /usr/share/dict/words.

Inactive generators

These generators are inactive by default. They can be turned on in the Configuration.

Pronounceable Markov Generator

Generates semi-pronounceable passwords based on Markov chains and the start of A Tale of Two Cities.

Has slightly more entropy than the Pronounceable Nonsense generator, but the passwords aren't quite as pronounceable.

Hexadecimal Generator

Generate passwords using hexadecimal characters (0-9, a-f).

German Generator

Generate passwords using the German alphabet, digits and punctuation.

German Alphanumeric Generator

Generate passwords using the German alphabet and digits without punctuation.

German Pronounceable Markov Generator

Generates semi-pronounceable passwords based on Markov chains and the start of Buddenbrooks.

Custom generators

You can easily add your own custom password generators. These must be placed in the directory ~/Library/Application Support/Alfred 2/Workflow Data/net.deanishe.alfred-pwgen/generators/. If you put your custom generators in the workflow itself, they will be deleted when the workflow is updated. You can quickly open up the above directory by entering the Alfred-Workflow magic argument workflow:opendata as your query, e.g. pwconf workflow:opendata.

Note: Your generators will be deactivated by default. You must manually activate them using pwconf to use them.

Modules containing your custom generators must be named gen_XXX.py.

Only files matching the pattern gen_*.py will be imported.

Your generator classes must subclass generators.PassGenBase or generators.WordGenBase, which are abstract base classes, and must have id, name, description and data properties. These have the following purposes:

Property Purpose
id Short name for your generator; used internally.
name The human-readable name; shown in the configuration.
description The longer description shown beneath the generator name in the configuration.
data Return a sequence of the characters to generate passwords from.

The data property is used by the entropy property and password() method on the PassGenBase base class.

PassGenBase is designed for character-based passwords, i.e. data returns a string or other sequence of single characters. WordGenBase is for word-based passwords, i.e. data returns a sequence of multi-character strings. The main difference is in the implementation of length-based passwords.

Important: data must return a sequence (string, list or tuple) not a generator or set. If random.choice() chokes on it, it's no good.

Examples

A generator to produce German passwords (i.e. possibly including letters like 'ΓΌ' or 'Γ€'):

import string
from generators import PassGenBase, punctuation
# punctuation is `string.punctuation` minus a few
# problematic/hard-to-type symbols (e.g. backslash)

class GermanGenerator(PassGenBase):
    """Generate passwords containing umlauts."""

    @property
    def id(self):
        return 'deutsch'

    @property
    def name(self):
        return 'German'

    @property
    def description(self):
        return 'German alphabet, digits and punctuation'

    @property
    def data(self):
        return string.ascii_letters + string.digits + punctuation + 'ΓΌΓ€ΓΆΓœΓ„Γ–ΓŸ'

A word-based generator to produce Swedish passwords might look like this:

from generators import WordGenBase

class BorkGenerator(WordGenBase):
    """Bork-bork-bork"""

    @property
    def id(self):
        return 'bork'

    @property
    def name(self):
        return 'Bork'

    @property
    def description(self):
        return 'Borked password generator'

    @property
    def data(self):
        return ['bork', 'bork', 'bork']

Licensing, thanks

This workflow is released under the MIT Licence, which is included as the LICENCE file.

The code for the Markov chain comes from a SimonSapin snippet, and the gibberish-generating code is from a Greg Haskins StackOverflow answer.

It is heavily based on the Alfred-Workflow library, also released under the MIT Licence.

The workflow icon is from the Elusive Icons webfont (licence).

The other icons are based on the Font Awesome webfont (licence).

Changelog

Version 1.0 (2015-07-28)

Initial release

Version 1.1 (2015-07-28)

  • Replace default Markov pronounceable generator with gibberish
  • Rename Dictionary generator module
  • Add licence and licensing info
  • Improve usage description in README
  • Add generator descriptions to README
  • Add strength bar toggle to configuration
  • Improve filtering in configuration

Version 1.2 (2015-07-31)

  • Add separate base class for word-based generators
  • Add custom (user) generator support
  • Refactor built-in generators

Version 1.3 (2015-11-03)

  • Change id_ property of generators to id

Version 2.0 (2017-02-26)

  • Icons reflect password strength
  • Alfred 3 only
  • Option to turn notifications off #3
  • Fix syntax error #5

Version 2.0.1 (2017-04-01)

  • Fix paste #7

Version 2.0.2 (2017-04-01)

  • Fix hanging background processes #4
  • New icons

Version 2.1 (2017-04-02)

  • Default to "concealed" copy so clipboard managers will ignore the passwords

Version 2.1.1 (2017-04-19)

  • Update dependencies

Version 2.1.2 (2017-12-10)

  • Update dependencies

Version 2.1.3 (2019-07-13)

  • Add Alfred 4 support

More Repositories

1

alfred-workflow

Full-featured library for writing Alfred 3 & 4 workflows
Python
2,970
star
2

awgo

Go library for Alfred 3 + 4 workflows
Go
859
star
3

alfred-convert

Convert between different units in Alfred
Python
721
star
4

zothero

Rapidly search and cite Zotero entries from Alfred
Python
477
star
5

alfred-stackexchange

Search StackOverflow.com from Alfred
Python
434
star
6

alfred-fixum

Fix Alfred 3 Python workflows affected by the Sierra/Alfred-Workflow background process bug
Python
369
star
7

alfred-ssh

Open SSH/SFTP/mosh connections from Alfred 3+
Go
356
star
8

alfred-firefox

Search and control Firefox from Alfred
Go
342
star
9

alfred-repos

Browse, search and open Git repositories in Alfred
Python
313
star
10

alfred-searchio

Alfred workflow to auto-suggest search results from multiple search engines and languages.
HTML
306
star
11

alfred-fakeum

Generate fake test data in Alfred
Python
288
star
12

alfred-gcal

View Google Calendar events in Alfred
Go
222
star
13

alfred-reddit

Browse Reddit from Alfred
Python
214
star
14

alfred-safari-assistant

Alfred 3+ workflow to search and use Safari bookmarks, history, reading list and tabs.
Go
190
star
15

alfred-vpn-manager

Manage Tunnelblick & Viscosity VPN connections from Alfred
Python
154
star
16

alfred-smartfolders

Quick access to your Smart Folders (Saved Searches) from Alfred
Python
119
star
17

alfred-fuzzy

Fuzzy search helper for Alfred 3+ workflows
Python
93
star
18

alfred-appscripts

Alfred workflow to search and run/open AppleScripts for the active application
Python
87
star
19

alfred-sublime-text

Filter and open your Sublime Text (2 and 3) project files from Alfred.
Go
73
star
20

i-sheet-you-not

Automagically turn Excel spreadsheets into Alfred 3 Workflows
Python
67
star
21

alfred-mailto

Send emails to recipients and groups from Alfred
Python
64
star
22

alfred-fuzzyfolders

Fuzzy search across folder subdirectories
Python
57
star
23

alfred-unicode

Preview Unicode characters and emoji in Alfred
Go
57
star
24

alfred-booksearch

Search Goodreads.com from Alfred
Go
56
star
25

alfred-similar-image-search

Google Image searches based on local files via Alfred
Python
50
star
26

alfred-packal-search

Search Packal.org's collection of Alfred workflows from Alfred
Python
43
star
27

alfred-services

Run macOS services from Alfred
Go
39
star
28

go-safari

Access Safari bookmarks, reading list, history and tabs (macOS)
Go
38
star
29

alfred-relative-dates

Alfred workflow to generate relative dates in different locales
Python
35
star
30

alfred-network-location

List, filter and activate network locations from within Alfred
Python
32
star
31

alfred-duden

Search the duden.de German dictionary from Alfred. With auto-suggest.
Python
32
star
32

alfred-index-demo

Demonstration of using sqlite as a search index in Alfred
Python
26
star
33

alfred-default-folder-x

Access your Default Folder X favourites and recent items in Alfred
Python
25
star
34

alfred-forklift

Filter ForkLift favourites in Alfred
Go
23
star
35

alfred-resolve-url

Alfred workflow to resolve HTTP redirects and return the canonical URL
Python
14
star
36

alfred-gifs

Say it with GIFs (and Alfred)
Python
12
star
37

bundler-icon-server

Generate PNG icons from icon fonts like Font Awesome
HTML
12
star
38

go-env

Access environment variables & populate structs from them
Go
11
star
39

alfred-errnum

Search macOS errors in Alfred 3
Python
10
star
40

alfred-mpd

Control mpd music player from Alfred 3
Python
9
star
41

go-fuzzy

Fuzzy matching & sorting for Go
Go
9
star
42

alfred-glosbe

Translate in Alfred using Glosbe.com
Python
8
star
43

CopyLink.mmBundle

MailMate Command to copy a link to the currently selected email
Python
8
star
44

alfred-transmit

Rapidly search Transmit favourites in Alfred
Go
5
star
45

alfred-bundler-python-demo

Demo Workflow showing how to use the Alfred Bundler in Python
Python
5
star
46

cookiecutter-alfred-workflow

cookiecutter template for Alfred 2 workflows
Python
4
star
47

alfred-star-ratings

Add star ratings to your files on OS X with Alfred
Python
4
star
48

alfred-excel-demo

Demo workflow showing how to use an Excel file as a data source for an Alfred Script Filter
Python
4
star
49

alfred-reminders-demo

Goto lists in Reminders.app
Python
3
star
50

bundler-icon-server-iconpacks

Icon packs for Bundler Icon Server
2
star
51

alfred-subdir-search

Alfred 2 Workflow to search subdirectories
Python
2
star
52

alfred-flixsearch

Search FlixSearch.io from Alfred 2
Python
2
star
53

www.deanishe.net

Hugo static site source
Go
1
star
54

just-a-test

Test Repo for GH API
1
star
55

alfred-workflow-dummy

A dummy repo for testing Alfred-Workflow's update functionality
Python
1
star
56

deanishe.github.io

Generated contents of www.deanishe.net
HTML
1
star