API Reference¶
Core modules¶
dispass.algos¶
The algos module is the most important part of DisPass. The algorithms DisPass uses to create the passphrases are defined as separate classes in the dispass.algos 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
-
static
-
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
-
static
-
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¶
Password manager for GNU/Linux, *BSD, MacOS X and Windows.
-
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.
-
Interface modules¶
dispass.cli¶
-
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
-
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¶
-
class
dispass.gui.
GUI
(settings, filehandler)[source]¶ Houses all GUI related objects and interactions
-
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
-
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
-
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
-
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
- A tuple with 5 values
-
longest_label
= None¶ Int. Length of the longest labelname of labelfile. Set on refresh()
-
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.
-
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
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
-
run
()[source]¶ Parse the various arguments and output passphrases for each label
Each positional argument is a label. For each label, it will try to find (via FileHandler.labletup) if it is in the labelfile so other settings for the label can be applied. If it is not found, the default settings object defined as dispass.dispass.settings will be used. The parameters can be overridden through the various optargs.
-
dispass.commands.gui¶
Subcommand module gui; contains only a single class Command
dispass.commands.help¶
Subcommand module help; contains only a single class Command
dispass.commands.increment¶
Subcommand module increment; contains only a single class Command
dispass.commands.list¶
Subcommand module list; contains only a single class Command
dispass.commands.remove¶
Subcommand module remove; contains only a single class Command