SRL Archive - Research & Development Lounge

Function: Password Maker


smithsps

2008-03-17 07:17:16

I made a password maker function for people making new accounts
and such.
I plan on continuing this with a account maker. :spot:

If you plan on using this Plus Rep ++ please.
function PassMaker(lengthofpass: integer): string;
var
chars, pass, passpart : string;
B, passnum : integer;
begin
chars := 'abcd efgh ijk lmnopqrs tuvwxyz123 45678 90';
passnum := 0;
repeat
passnum := passnum + 1;
B := random(42) + 1;
passpart := copy(chars, B, 1);
insert(passpart, pass, passnum);
until(passnum = lengthofpass);
result := pass;
end;

Sample Script: Just spits out passwords according to the length you set it.
program Passmaker;

function PassMaker(lengthofpass: integer): string;
var
chars, pass, passpart : string;
B, passnum : integer;
begin
chars := 'abcd efgh ijk lmnopqrs tuvwxyz123 45678 90';
passnum := 0;
repeat
passnum := passnum + 1;
B := random(42) + 1;
passpart := copy(chars, B, 1);
insert(passpart, pass, passnum);
until(passnum = lengthofpass);
result := pass;
end;

begin
cleardebug;
writeln(PassMaker(8));
end.

Narcle

2008-03-17 07:32:13

There is a easier way:
Function PassMaker(Len:integer):string;
var
I:integer;
Cha:string;
begin
Cha := 'abcdefghijklmnopqrstvuwxyz0123456789';
for I := 1 to Len do
result := result + Cha[random(Length(cha))+1];
end;

Didn't want to brag, okay maybe a little. But there is faster and shorter ways for randomizing strings. I've used this quite a bit.

Check out my Name Generator too.

bullzeye95

2008-03-17 07:43:35

It can get even shorter than that…
function MakePassword(Length: Integer): String;
var
I: Integer;
begin
for I:= 1 to Length do
Result:= Result + String('abcdefghijklmnopqrstvuwxyz0123456789')[Random(36) + 1];
end;
:)

n3ss3s

2008-03-17 09:16:04

You both got pwned by a junior member… Like I got yesterday…

I think it was Mixter - the function was something like this:


Function Password(Len: Integer): String;

Begin
While Length(Result) < Len Do
Result := Result + Chr(65 + Random(26));
End;

Even it calls length every round, I think that's a nice "invention" for a jr member… though I don't know did he make it himself, but anyways…


Narcle: You have the wrong idea about bragging :p

GoF

2008-03-17 09:21:33

From: n3ss3s


Function Password(Len: Integer): String;

Begin
While Length(Result) < Len Do
Result := Result + Chr(65 + Random(26));
End;


I was thinking of making something like that and posting here, but the good ol' laziness struck me again and I just decided to be useless as always.

Narcle

2008-03-17 13:32:50

From: n3ss3s
You both got pwned by a junior member… Like I got yesterday…

I think it was Mixter - the function was something like this:


Function Password(Len: Integer): String;

Begin
While Length(Result) < Len Do
Result := Result + Chr(65 + Random(26));
End;

Even it calls length every round, I think that's a nice "invention" for a jr member… though I don't know did he make it himself, but anyways…


Narcle: You have the wrong idea about bragging :p


Ha I like it.
Bragging… ha hardly. It was just to ease the suffering.

"You both got pwned by a junior member… Like I got yesterday…" Indeed.

Does the While really repeat for that? Looks ominous but if it works… thats all that matters.

Oh and "Length(Result) < Len" so the password is always Len-1 long?

P1nky

2008-03-17 14:47:57

so it will tell you the p.w in your debug?

ShowerThoughts

2008-03-17 15:09:24

nope…, add writln(result);
maybe inttostr needed to…

n3ss3s

2008-03-17 15:17:40

: String;


-.- @ Hermpie…

Oh and "Length(Result) < Len" so the password is always Len-1 long?


Consider again - if it was " <= " it would make it one letter longer ;)

bullzeye95

2008-03-17 15:38:44

From: n3ss3s
You both got pwned by a junior member… Like I got yesterday…

I think it was Mixter - the function was something like this:


Function Password(Len: Integer): String;

Begin
While Length(Result) < Len Do
Result := Result + Chr(65 + Random(26));
End;

Even it calls length every round, I think that's a nice "invention" for a jr member… though I don't know did he make it himself, but anyways…


Narcle: You have the wrong idea about bragging :p


I would have done something like how he did the result, but it can't do numbers… I didn't think of the while loop though, that was smart :)

mixster

2008-03-17 15:58:58

People always forget the 's' :(
I could've made it do numbers (like Bullzeye did with the String('abcetc.') but having a whole string there makes it not look as cool :p