The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



InventPassWord


Unit: SDL_filesys
Class: none
Declaration: [1] function InventPassword (NrChars: integer): string;
[2] function InventPassword (NrChars: integer; MixCases, SpecChars: boolean): string;

The function InventPassword creates a random character combination to be used as a password. It comes in two overloaded versions. Version [1] generates a password which is easy to read, i.e. the returned string consists of vowels and consonants and two digits in an appropriate order. The parameter NrChars determines the length of the created password and may assume values between 4 and 14.

Version [2] generates much more complicated passwords which are harder to remember but inherently safer. The additional parameter MixCases determines whether a mix of lower and upper case characters is used, or lowercase characters only. The parameter SpecChars determines whether special characters and digits are used in the generated password.

The number of different passwords generated by the algorithm depends on the parameter NrChars :

  number of possible different words(1)
NrChars MixCases=FALSE
SpecChars=FALSE
MixCases=TRUE
SpecChars=FALSE
MixCases=FALSE
SpecChars=TRUE
MixCases=TRUE
SpecChars=TRUE
4 12000 48000 202752 401408
6 1.44*106 2.30*107 1.61*108 6.29*108
8 1.73*108 1.11*1010 1.27*1011 9.87*1011
10 2.07*1010 5.31*1012 1.01*1014 1.55*1015
12 2.48*1012 2.55*1015 7.98*1016 2.43*1018
14 2.98*1014 1.22*1018 6.32*1019 4.70*1021

Hint: Don't forget to initialize the random generator which is used for generating the random character combinations (Delphi system call "randomize")



(1) Please note that version [1] of InventPassword corresponds to version [2] with both MixCases and SpecChars set to FALSE.


Last Update: 2023-Feb-06