ich habe mal vor ner Ewigkeit soetwas programmiert
Delphi-Quellcode:
function GenPW(const bSmallLetters, bBigLetters, bNumbers, bEasyToRemember: Boolean;
wLength: Word): String;
var
PossibleChars,
PossibleVocals: String;
pcLen, pvLen,
i: Integer;
const
aVocalsSmall: Array[0..4] of Char =
'aeiou';
aVocalsBig: Array[0..4] of Char =
'AEIOU';
aSmallLetters: Array[0..25] of Char =
'abcdefghijklmnopqrstuvwxyz';
aBigLetters: Array[0..25] of Char =
'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
aNumbers: Array[0..9] of Char =
'0123456789';
begin
if bSmallLetters then
begin
PossibleChars := String(aSmallLetters);
if bEasyToRemember then
PossibleVocals := String(aVocalsSmall);
end;
if bBigLetters then
begin
PossibleChars := PossibleChars + String(aBigLetters);
if bEasyToRemember then
PossibleVocals := PossibleVocals + String(aVocalsBig);
end;
if bNumbers then
PossibleChars := PossibleChars + String(aNumbers);
if Length( PossibleChars ) = 0 then
Result := ''
else
begin
Randomize;
SetLength(Result, wLength);
pcLen := Length(PossibleChars);
pvLen := Length(PossibleVocals);
for i := 1 to wLength do
if bEasyToRemember then
begin
if i mod 2 = 0 then
Result[i] := PossibleVocals[1+Random(pvLen)]
else
Result[i] := PossibleChars[1+Random(pcLen)];
end else
Result[i] := PossibleChars[1+Random(pcLen)];
end;
end;