API Reference

Core modules

dispass.algos

Passphrase algorithms

The algos module is the most important part of DisPass. The algorithms DisPass uses to create the passphrases are defined as separate classes in this module.

class dispass.algos.Dispass1[source]

Dispass1 algorithm

Tests:

>>> dispass1 = Dispass1()
>>> dispass1.digest('test', 'qqqqqqqq')
'Y2Y4Y2Y0Yzg5Nzc1Yzc2MmI4OTU0ND'
>>> dispass1.digest('test2', 'qqqqqqqq', 50)
'NmQzNjUzZTlhNTc4NWFlNTU5ZTVkZGQ5ZTc2NzliZjgzZDQ1Zj'
static digest(label, password, length=30, seqno=None)[source]

Create and return secure hash of message

A secure hash/message digest formed by hashing a string (formed by concatenating label+password) with the sha512 algorithm, encoding this hash with base64 and stripping it down to the first length characters.

Parameters:
  • label: String. Labelname
  • password: String. The input password
  • length: Length of output hash (optional)
  • seqno: Sequence number. Not used in Dispass1
Return:
  • The secure hash of label + password
class dispass.algos.Dispass2[source]

Dispass2 algorithm

Tests:

>>> dispass2 = Dispass2()
>>> dispass2.digest('test', 'qqqqqqqq')
'ZTdiNGNkYmQ2ZjFmNzc3NGFjZWEwMz'
>>> dispass2.digest('test2', 'qqqqqqqq', 50, 10)
'NGEwNjMxMzZiMzljODVmODk4OWQ1ZmE4YTRlY2E4ODZkZjZlZW'
static digest(label, password, length=30, seqno=1)[source]

Create and return secure hash of message

A secure hash/message digest formed by hashing a string (formed by concatenating label+seqno+password) with the sha512 algorithm, encoding this hash with base64 and stripping it down to the first length characters.

Parameters:
  • label: String. Labelname
  • password: String. The input password
  • length: Length of output hash (optional)
  • seqno: Integer. Sequence number.
Return:
  • The secure hash of label + seqno + password
dispass.algos.algoObject(algoname)[source]

Return an algorithm object

Parameters:
  • algoname: String. Name of the algorithm
Return:
  • An algorithm object or False
dispass.algos.algorithms = ('dispass1', 'dispass2')

A tuple of registrered algorithms, used for validation of user input

dispass.dispass

Contains settings object/instance, DisPassCommand object and version info

class dispass.dispass.DispassCommand(argv=['-b', 'html', '-d', '_build/doctrees', '.', '_build/html'])[source]

Main shell command object

run()[source]

The run method of the main command

This is the first point of entry that will parse the command and arguments given in the shell by the user, directing arguments to subcommands if applicable.

The subcommands are imported in this method, since doing it in the module itself causes circular import problems. There is support for dynamically loading the modules, so you can define custom commands. The (main) subcommands get imported explicitly so that ‘freezing’ apps like PyInstaller will correctly include the modules.

class dispass.dispass.Settings[source]

Global settings

algorithm = 'dispass1'

String. The algorithm to use, default is dispass1

disabled = False

Bool. Default disabled state

passphrase_length = 30

Int. Default passphrase length

sequence_number = 1

Int. Default sequence number

dispass.dispass.verboseVersionInfo()[source]

Returns a string with verbose version information

The string shows the version of DisPass and that of Python. It also displays the name of the operating system/platform name.

dispass.main

Main functions / setup.py script entry points for console and GUI.

dispass.main.console()[source]

Main function for dispass (command line)

dispass.main.gui()[source]

Main function for gdispass (GUI)

Interface modules

dispass.cli

Handling of password input and printing passphrases (using ncurses)

class dispass.cli.CLI(filehandler)[source]

Command Line Interface handling

generate(password, labeltup)[source]

Generate passphrase and store result in passphrases

Parameters:
  • password: Password to use for passphrase generation
  • labeltup: A tuple labeltup with 5 values:
    • label: Label to use for passphrase generation
    • length: Length to use for passphrase generation
    • algo: Algorithm to use for passphrase generation
    • seqno: Sequence number to use for passphrase generation
    • disabled: Whether or not the label is disabled
output()[source]

Output and flush passphrase(s)

passphrases = {}

Dict of labels and generated passphrases

passwordPrompt()[source]

Prompt for password

Use the getpass.getpass function to ask the user for the password and ensure it is 8 characters. The password will be asked twice if self.verifyPassword == True.

Return:Password string.
scriptableIO = False

Boolean. Optimize input/output for wrapping dispass

setCurses(useCurses)[source]

Optionally override self.useCurses

Instead of setting the instance variable self.useCurses directly, a setter is used to ensure it can only be set to True if the curses library is supported.

Parameters:
  • useCurses: Boolean
verifyPassword = False

Boolean. Prompt for password twice and save label to labelfile

dispass.gui

Module that houses all GUI related objects and interactions

class dispass.gui.GUI(settings, filehandler)[source]

GUI object with tkinter mainloop

clearIO()[source]

Clear all input and output fields

clearInput()[source]

Clear all input fields

clearOutput()[source]

Clear all output fields

createWidgets()[source]

Create and align widgets

filterLabels()[source]

Filter labels according to what was typed into the entry.

font = 'Verdana'

Default font (Verdana)

fontsize = 10

Default fontsize (10 pt.)

getFont(sizediff=0)[source]

Get font and fontsize, optionally differ from default fontsize

Parameters:
  • sizediff: The difference in pt. from the default fontsize
Return:
  • Tuple of (font, fontsize) to be used when creating widgets
labelFocusOut(event)[source]

Set values of input fields according to the selected label.

labelSelected(event)[source]

Change focus to password field.

reset()[source]

Clear all input and output and focus label entry

toggleCheck()[source]

Toggle checking of input password

validateAndShow()[source]

Check user input

Warn when user input is insufficient or wrong. Create digest and display the generated password if user input is OK.

warn(message, warning_type='soft', box_title='')[source]

Prototype for warning user

  • soft warnings display a message in the passwordout field
  • hard warnings do the same and also display a messagebox
Parameters:
  • message: The message string for warning the user
  • warning_type: Either ‘soft’ (default value) or ‘hard’
  • box_title: Optional title for tkMessageBox on hard warnings

dispass.filehandler

Dispass labelfile handler

class dispass.filehandler.Filehandler(settings, file_location=None)[source]

Parsing of labelfiles and writing to labelfiles

add(labelname, length=None, algo=None, seqno=None, disabled=False)[source]

Add label to labelfile

disable(labelname, disabled=True)[source]

Disable or enable a label

file_found = None

Boolean value set on init

file_location = None

String of labelfile location, set on init

filehandle = None

File object, set on init if labelfile is found

getDefaultFileLocation()[source]

Scan default labelfile paths

increment(labelname)[source]

Increment sequence number of labelfile

labelfile = []

List of [(labelname, length, algorithm, seqno, disabled), … ]

labeltup(label)[source]

Get labeltup for label

Parameters:
  • label: The labelname
Returns:
  • A tuple with 5 values (label, length, algo, seqno, disabled))
    • label: Label to use for passphrase generation
    • length: Length to use for passphrase generation
    • algo: Algorithm to use for passphrase generation
    • seqno: Sequence number to use for passphrase generation
    • disabled: Whether or not the passphrase is disabled
longest_label = None

Int. Length of the longest labelname of labelfile. Set on refresh()

parse()[source]

Create dictionary {algorithm: (label, (length, seqno, disabled))}

printLabels(fixed_columns=False, labels_only=False, all_=False)[source]

Print a formatted table of labelfile contents

Parameters:
  • fixed_columns: Boolean.
  • labels_only: Boolean.

If labels_only is True, only the labelnames will be printed.

If fixed_columns is true the output will be optimized for easy parsing by other programs and scripts by not printing the header and always printing one entry on a single line using the following positions:

  • Column 1-50: labelname (50 chars)
  • Column 52-54: length (3 chars wide)
  • Column 56-70: hash algo (15 chars wide)
  • Column 72-74: sequence number (3 chars wide)
  • Column 76-77: disabled (1 char wide)

If fixed columns is false an ascii table is printed with a variable width depending on the length of the longest label.

promptForCreation(silent=False)[source]

Create the labelfile, optionally warning the user beforehand

Parameters:
  • silent: When True, the user will not be warned.
Returns:

Boolean. Indicating if the labelfile was created succesfully.

refresh(sort=True)[source]

Sort labelfile on labelname and get longest label

remove(labelname)[source]

Remove label from labelfile

save()[source]

Save labelfile to file

update(labelname, length=None, algo=None, seqno=None, disabled=None)[source]

Update label in labelfile

dispass.interactive_editor

User interface module for altering labelfiles

class dispass.interactive_editor.InteractiveEditor(settings, filehandler, interactive=False)[source]

User interface object for altering labelfiles

filehandler = None

Filehandler object

read_label()[source]

Keep bugging the user for a label until they crack and give us one.

Subcommand modules

Subcommands are defined in the dispass.commands package as separate modules containing a class derived from pycommand.CommandBase.

dispass.commands.add

Subcommand module add; contains only a single class Command

class dispass.commands.add.Command(argv=['-b', 'html', '-d', '_build/doctrees', '.', '_build/html'])[source]

Add a new label to the labelfile and generate passphrase.

dispass.commands.generate

Subcommand module generate; contains only a single class Command

class dispass.commands.generate.Command(argv=['-b', 'html', '-d', '_build/doctrees', '.', '_build/html'])[source]

Generate passphrases for one or more labels

dispass.commands.gui

Subcommand module gui; contains only a single class Command

class dispass.commands.gui.Command(argv=['-b', 'html', '-d', '_build/doctrees', '.', '_build/html'])[source]

Start the graphical version of DisPass

dispass.commands.help

Subcommand module help; contains only a single class Command

class dispass.commands.help.Command(argv=['-b', 'html', '-d', '_build/doctrees', '.', '_build/html'])[source]

Show help information

dispass.commands.increment

Subcommand module increment; contains only a single class Command

class dispass.commands.increment.Command(argv=['-b', 'html', '-d', '_build/doctrees', '.', '_build/html'])[source]

Increment the sequence number of a label

dispass.commands.list

Subcommand module list; contains only a single class Command

class dispass.commands.list.Command(argv=['-b', 'html', '-d', '_build/doctrees', '.', '_build/html'])[source]

Print a formatted table of labelfile contents

dispass.commands.remove

Subcommand module remove; contains only a single class Command

class dispass.commands.remove.Command(argv=['-b', 'html', '-d', '_build/doctrees', '.', '_build/html'])[source]

Remove label from labelfile

dispass.commands.version

Subcommand module version; contains only a single class Command

class dispass.commands.version.Command(argv=['-b', 'html', '-d', '_build/doctrees', '.', '_build/html'])[source]

Show full version information