This is a simple tip and for working with wireless networks can be very useful. What function does is generate a string of hexadecimal characters, but can be adapted for any other type. This function takes as parameters the password length as an integer, and three parameters of type boolean indicating whether these are lowercase, uppercase and numbers.
PHP Code:
GeraSenhaHex function (Digits: Integer; Min: Boolean; Mai: Boolean; Num: Boolean): string;
const
MinC = 'abcdef';
MAIC = 'abcdef';
NUMC = '1234567890 ';
var
p, q: Integer;
Char, Password: String;
begin
Char: ='';
If Char then Min: = Char + MinC;
If Mai then Char: Char = + MAIC;
If a then Char: Char = + NUMC;
for p: = 1 to the Digits
begin
Randomize;
q: = Random (Length (Char)) + 1;
Password: Password = + Char [q];
end;
Result: = Password;
end;
explanations:
First we create the constant that will bring the characters referring to lowercase, uppercase, numbers and then began to empty, only by discharge of consciousness since Delphi does this by default, the variable "
Char", which will contain all the characters be used for random password generation.
After that, we test parameters to uppercase, lowercase and numbers, adding to the "
Char" each of which are true according to the parameters passed in function call.
And then, to finish, a tie with the number of repetitions equal to the digits also passed as a parameter in the call that function using the Random delphi generates random numbers within the limit set by the variable performance of "
Char", noting that the fact add "+ 1" is for the positions of characters within a string start at 1, and the function generates Random numbers from 0 up to the amount stipulated as the limit. For example a String = 'test' have the following values:
String [1] = 't'
String [2] = 'e'
String [3] = 's'
String [4] = 't'
String [5] = 'e'
Finished. Simple, easy and very useful.