Script Control of the PasswordGenerator
In addition to creating passwords using the program's graphical user interface, the PasswordGenerator in its desktop version also offers the option of generating passwords within scripts or via the command line. We will explain how this works in the following.
- How to start the Password Generator in Batch Mode
- Influence the Length of the Password
- Influence the Character Classes used for the Password
- Influence the Characters of the Character Classes
- Influence the Minimum Usage of the Character Classes
- Unique, similar and adjacent Characters
- Load Configuration Files
- Overview of all available Parameters
Batch Mode
To put the Password Generator in batch mode, only one parameter is required. Simply call the Password Generator via the command line or within a script with the parameter -cl (stands for command line):
PasswortGenerator -cl
With this, the Password Generator starts in batch mode without a graphical user interface. The program automatically generates a password immediately after starting, outputs this via the command line and then exits itself again.
Since this call does not contain any further parameters, the standard settings are used for generating the password. These are either the default settings of the Password Generator or the start settings, if you have saved any.
Influence the Length of the Password
The first interesting parameter with which you can set the desired length of your password is the parameter l. Simply write after l= how long your password should be. A call can look like this, for example:
PasswortGenerator -cl l=16
With this line you create a password with 16 characters. In addition, the default settings of the Password Generator are used for the password. If you omit the "l" parameter, the default settings are used for the password length.
Influence the Character Classes used for the Password
In the PasswordGenerator there are 4 character classes available for your passwords: uppercase letters, lowercase letters, digits and special characters. With the parameter "c" (for character classes) you can determine in batch mode from which character classes your password should be built.
For each character class there is a letter: u (uppercase) stands for uppercase letters, l (lowercase) stands for lowercase letters, d (digits) for numbers and s (special characters) for special characters. The letters can be freely combined with each other.
You can specify the letters for all character classes if characters from all character classes should be used for your password:
PasswortGenerator -cl c=ulds
If only uppercase letters, lowercase letters and numbers should be used, omit the s for special characters and only pass the other three letters:
PasswortGenerator -cl c=uld
If only digits should be used, just pass only the d (digits) as a parameter:
PasswortGenerator -cl c=d
The parameters can be mixed freely. If you need, for example, an 8-character password consisting of uppercase and lowercase letters, you can use the following command:
PasswortGenerator -cl l=8 c=ul
On the other hand, if you omit some or even all of these parameters, the program's default settings are used.
Please note that even if you specify via the parameter "c=ulds" that all character classes may be used for your password, coincidence can nevertheless lead to some of the character classes being missing from your password. If you want to prevent this, you can use the parameter "m" like this:
PasswordGenerator -cl l=6 c=ulds m=1
With "m=1" you ensure that at least one character of each selected character class must be used ("m" stands for "minimum"). With this command we create passwords with six characters (l=6) that contain at least one uppercase letter, one lowercase letter, one digit and one special character. You can learn more about the m-parameter in the section on minimum character class usage. There you will also find out how you can set individual minimum numbers for individual character classes.
You can specify which characters are used for the individual character classes in the program settings via the graphical user interface. If these are then saved as start-up settings, your settings will also be used automatically in batch mode. Alternatively, you can define the characters for the character classes also directly using parameters (as we will look at in the next section) or you can specify the definitions via configuration files (which we will look at in the penultimate section of this tutorial).
Influence the Characters of the Character Classes
By default, the character classes contain the characters that you can find in the password generator settings. This means, for example, if you select the character class "uppercase letters" using the parameter "c=u", (without any further setting modifications) your password will consist of the letters A to Z, or if you select both the character class "lowercase letters" as well as the class "digits" using "c=ld", the letters a to z and the numbers 0 to 9 will be used to generate your password.
As already mentioned in the last section, one way to change the default set of characters is to set the password generator startup settings via the graphical user interface or to pass configuration files as a parameter. Another possibility is to define the character sets directly using the parameters "cu" (uppercase letters for "characters uppercase"), "cl" (lowercase letters for "characters lowercase"), "cd" (digits for "characters digits") as well as "cs" (special characters for "characters special"). We would like to take a look at how this works below.
PasswordGenerator -cl l=8 c=uld cu=ABC cl=abc cd=123
With this line we create a password consisting of eight characters (l=8). As character classes, we have selected uppercase letters (u) as well as lowercase letters (l) and digits (d) using "c=uld". Additionally, we have defined each of these three character classes with three characters each. As uppercase letters, only the letters A, B and C should be used (cu=ABC), as lowercase letters, only the letters a, b and c (cl=abc) and as digits the numbers 1, 2 and 3 (cd=123).
Which character classes we define at all and which characters our definition ultimately includes is entirely up to us. We are completely free and therefore not even tied to the fact that the name of the character class matches the defined characters:
PasswordGenerator -cl l=12 c=ulds cs=Aa
As an example, here we want to generate a password with twelve characters and use "c=ulds" to specify that this password should contain characters from all character classes. However, we only give one definition of the character class "Special Characters" using "cs=Aa", so that the standard settings will apply for the other three character classes "uppercase letters", "lowercase letters" and "numbers". Our definition with "A" and "a" also contains no special characters at all, but rather both an uppercase letter and a lowercase letter, which would actually belong to other classes. We can use this approach, which seems paradoxical at first glance, to weight the frequency of different characters differently, as we will see later.
In our examples so far, we have deliberately kept our character definitions short so that the examples remain clear. Of course, in practice we would define many more characters to get a stronger password. So that we don't have to define each character individually, which can make the definitions confusingly long, the password generator alternatively offers us the option of defining characters using Unicode codepoint ranges:
PasswordGenerator -cl l=8 c=uld cu=65-90 cl=97-122 cd=48-57 u=1
We signal that the password generator should interpret our information as code points using the parameter "u=1". If you would write "u=0" instead or leave this parameter out completely, the characters will be adopted as such.
In our example, we create a password with a length of eight characters (l=8), which should be created from the character classes uppercase, lowercase and numbers (c=uld). Each of these three character classes we have defined using decimal codepoint ranges: the uppercase letters via the codepoints 65 to 90, which correspond to the characters A to Z, the lowercase letters using the codepoints 97 to 122, which correspond to the characters a to z, and the digits using the codepoints 48 to 57, which correspond to the characters 0 to 9.
In addition to this decimal notation, the code points can also be specified in a hexadecimal way. The letter "A" can thus be specified both decimal as "66" as well as hexadecimal in one of the forms #41, 0x41 or U+0041. In addition to individual code points and the ranges we just looked at, it is also possible to use enumerations of several code points or ranges:
PasswordGenerator -cl l=10 c=s cs=65-90,#61-#7A,U+0021 u=1
In this example, we have defined the character class "Special Characters" using a mix of different notations. The character class here contains the letters A to Z (defined via their decimal code points 65 to 90), the letters a to z (defined via their hexadecimal code points #61 to #7A) as well as the exclamation mark, which was defined as a single character via its code point U+0021. Using this character set (c=s), we create passwords with ten characters (l=10) when executing this line. If we had omitted "u=1" (interpretation as codepoints), the passwords would have been created from all the characters individually listed here such as "6", "5", "-", "9" and so on, since the characters would have been interpreted as such and not as codepoints. To mix both codepoints and characters as such within a single definition, you can enclose the characters that should be interpreted as such in quotation marks within the collection.
Influence the Minimum Usage of the Character Classes
Even if you use the parameter "c=ulds" to specify that characters from all character classes may appear in the generated password, chance can still lead to characters from only single or even only one character class appearing in your password. With this parameter alone, the characters from all character classes are thrown into a large pot, from which the characters for your password are then randomly drawn. And these can just happen to be only the characters of a certain class, especially if the other character classes contain significantly fewer characters than this class. This doesn't even have to apply exclusively to self-defined character classes of small size, because also the treasure trove of letters is significantly larger than that of numbers.
If you don't want to leave it up to chance whether each character class will be represented in your password, you can control the presence of all character classes via the parameter "m" and its relatives:
PasswordGenerator -cl l=8 c=ulds m=1
With this command we create an eight-character password (l=8), which should be generated from all character classes (c=ulds) and should contain at least one character from each of these character classes (m=1). The "m" stands for "minimum" and can define any minimum number. You just have to make sure that this minimum number does not contradict the other parameters.
PasswordGenerator -cl l=15 c=uld m=5
In this example, with "m=5", we demand a total of five characters taken from each of the three character classes available for use ("c=uld"). To meet this requirement, our password must have a minimum length of 15 characters (as it is exactly defined here with "l=15"). Otherwise, it would not be possible to accommodate five characters from three character classes in shorter passwords.
The parameter "m" always refers to all character classes equally. In addition to this general minimum number parameter, there are four additional other parameters with which you can control the minimum number of each of the single character classes individually. These are the parameters "mu" (for "min uppercase"), "ml" (for "min lowercase"), "md" (for "min digits") and "ms" (for "min special characters"). These parameters can be used individually or in combination with "m".
PasswordGenerator -cl l=9 c=uld mu=3 ml=3 md=1
Here we use the parameters individually. We create a password with nine characters (l=9) made up of uppercase letters, lowercase letters and digits (c=uld). In order to compensate for the fact that the number of digits (0 to 9) is almost three times smaller than the number of letters (A to Z and a to z), we determine that both the uppercase letters (mu=3) as well as the lowercase letters (ml=3) should appear at a minimum of three times in our password, but the digits should only appear at a minimum of one time. This reduces the possible overrepresentation of the same digits.
Exactly the same result, we would also achieve with the following line:
PasswordGenerator -cl l=9 c=uld m=3 md=1
Here we have replaced the parameters "mu=3" and "ml=3" with "m=3". This means that the general parameter "m=3" initially sets the minimum number for all character classes to "3", which is then overwritten by "md=1" only for the digits. By combining the general with the specific parameters, we can save up to two parameters, as we see in the next example, where instead of the 19 characters "mu=1 ml=1 md=1 ms=0" only the 8 characters "m=1 ms=0" are sufficient for the same result:
PasswordGenerator -cl l=6 c=ulds m=1 ms=0
A peculiarity here is the parameter "ms=0", which does not mean that special characters should not appear in the password at all, but only that the minimum number of special characters is set to 0. In other words, special characters are allowed to appear in the password (if chance would have it that way), but they don't have to because there is no minimum requirement. With this line we create a password with six characters (l=6), which is generated from all character classes (c=ulds). We then initially require a general minimum number of one character per character class (m=1), but then revise this requirement only for the special characters (ms=0).
Before the introduction of the "m" parameter family, the parameter "a" took on a similar role. With "a=1" it was possible to force that at least one character from each desired character class appears in the password (a stands for "all"). With the introduction of the much more flexible parameter "m", with which an exact number of the required characters from each character class could be specified (and not just "at least one" as with the parameter "a"), the parameter "a" lost its meaning. However, this parameter is currently still supported, but has been downgraded to the status"deprecated" and should therefore be replaced in the future by "m=1", which has exactly the same meaning.
Unique, similar and adjacent Characters
As you know from the graphical user interface of the password generator, there are three additional options for the password generation available that we have not looked at so far. Those option are also available through parameters via the script control, which we would like to take a look at in the following three examples.
PasswordGenerator -cl l=25 o=1
With this line we want to create a 25 character password. Generating a password of this length can quickly lead to individual characters appearing twice or even more often in the password. If we do not want this, we can use the parameter "o=1" to ensure that each character may only be used once (the "o" stands for "only once"). Just like with the parameters for the minimum number of characters to be used from the character classes, also when using this parameter, we have to ensure that the number of characters available is sufficient for our password length, even if each one can only be used once.
PasswordGenerator -cl l=6 es=1
With this line we create a password with only six characters and pass the parameter "es=1". The "es" stands for "exclude similar" and ensures that similar-looking characters such as O, 0, 1, I or l are excluded. This function can be useful to prevent misunderstandings when typing the password, for example if a password has to be passed on in printed form. Without this simplifying parameter, the character classes themselves would have to be laboriously redefined. This means that the similar-looking characters do not need to be additionally removed from the relevant character classes - it is sufficient to just use this parameter.
PasswordGenerator -cl l=10 ri=1
The last option we would like to introduce in this section is the parameter "ri=1", which stands for "reduce identicals". Specifically, this parameter reduces the probability of two identical characters appearing one after the other in the created password (which cannot happen anyway when using the parameter "o=1" that we have seen at the beginning of this section).
Otherwise - even if we have deliberately kept the examples in this section short for the sake of clarity - the parameters presented here can of course also be freely combined with all the other parameters that have been introduced so far in this tutorial.
Load Configuration Files
Settings that you have made via the graphical user interface of the Password Generator can be saved via Settings > Save as a file in the *.pgs format (Password Generator Settings). In addition to the length and the character classes used, you can also define, for example, which characters should belong to which character class.
To use these configuration files in batch mode, they only have to be passed as parameters as follows:
PasswortGenerator -cl config.pgs
If the configuration file is not in the same directory as the program file, the path to the file must of course also be specified:
PasswortGenerator -cl c:\ordner\config.pgs
The configuration files can be used freely with any other parameters:
PasswortGenerator -cl config.pgs l=20 c=ds
The following applies: First, the default settings of the Password Generator are loaded. If available, these will be overwritten with the start settings. These are then in turn overwritten by any configuration files that may have been passed (the settings files can also only contain parts of the possible settings). Last the settings are overwritten with the parameters. The parameters always have the highest priority.
Overview of all available Parameters
In summary, the following table provides an overview of all available parameters that you can use in the batch mode of the Password Generator.
| Parameter | Values | Default | Description |
| l | numbers > 0 | standard setting of the program | Desired length of the password. For example, you can use l=10 to create a 10-character password. |
| c | u, l, d, s - freely combinable | standard setting of the program | Desired character classes for the password. The individual letters stand for uppercase letters (u), lowercase letters (l), digits (d) and special characters (s) and can be freely combined with one another. For example, you can use c=ulds for passwords made of all character classes, c=ul for passwords with uppercase and lowercase letters, or c=d for passwords that only consist of digits. |
| cu | any characters | standard setting of the program | Definition of the characters for the character class "uppercase" (characters uppercase). For example, with "cu=ABC" the letters "A", "B" and "C" are used as "capital letters". Alternatively, if this parameter is combined with "u=1", the characters can also be defined using their Unicode Codepoints. |
| cl | any characters | standard setting of the program | Definition of the characters for the character class "lowercase" (characters lowercase). For example, with "cl=abc" the letters "a", "b" and "c" are used as "lowercase letters". Alternatively, if this parameter is combined with "u=1", the characters can also be defined using their Unicode codepoints. |
| cd | any characters | standard setting of the program | Definition of the characters for the character class "digits" (characters digits). For example, with "cd=123" the digits "1", "2" and "3" are used as "digits". Alternatively, if this parameter is combined with "u=1", the characters can also be defined using their Unicode codepoints. |
| cs | any characters | standard setting of the program | Definition of the characters for the character class "special characters" (characters special). With "cs=!?", for example, the characters "!" and "?" are used as "special characters". Alternatively, if this parameter is combined with "u=1", the characters can also be defined using their Unicode codepoints. |
| u | 0 or 1 | 0 | With "u=1" the character classes defined by "cu", "cl", "cd" and "cs" are interpreted as Unicode Codepoints. The specification can be made in the form of individual code points (e.g. 66, #41, 0x41 or U+0041 for "A"), as a range (e.g. 66-68 for "ABC") or as a list of several code points or ranges (e.g. #41,#42,#44-#46 for "ABDEF"). |
| m | any number | standard setting of the program | Minimum number of characters to be used from each character class for the password. For example, "m=2" to use at least two characters from each selected character class for the password. The general minimum number specified by this parameter can be overridden for individual character classes using the parameters "ml", "mu", "md" and "ms". |
| mu | any number | number defined via parameter “m” | Minimum number of capital letters (min uppercase) to be used for the password. Overrides the value specified by parameter "m". |
| ml | any number | number defined via parameter “m” | Minimum number of lowercase letters (min lowercase) to be used for the password. Overrides the value specified by parameter "m". |
| md | any number | number defined via parameter “m” | Minimum number of digits (min digits) to be used for the password. Overrides the value specified by parameter "m". |
| ms | any number | number defined via parameter “m” | Minimum number of special characters (min special chars) to be used for the password. Overrides the value specified by parameter "m". |
| a | 0 or 1 | standard setting of the program | Should at least one character from each specified character class be used for each password? Yes (1) or No (0). This parameter is classified as "deprecated". Instead, please use the parameter “m” in the form “m=1” now. |
| o | 0 or 1 | standard setting of the program | Should each character only be used a maximum of once (only once)? Yes (1) or No (0). |
| es | 0 or 1 | standard setting of the program | Should similar-looking characters such as O, 0, 1, I or l be excluded (exclude similar)? Yes (1) or No (0). |
| ri | 0 or 1 | standard setting of the program | Should the probability of two identical characters in a row be reduced (reduce identicals)? Yes (1) or No (0). |
| [Files] | configuration files with the extension PGS | standard setting of the program | Configuration file that can be created with the Password Generator and that can contain all settings including the characters used for the individual character classes. |
All available parameters can be combined with one another as required. The single parameters such as l, c and so on have a higher priority than possible configuration files.