PDA

View Full Version : RandomStringGenerator



Jackrawl
12-09-2007, 12:02 AM
procedure RandomStringGenerator;
var
P : Integer;
Spam : String;
begin
for P := 0 to (2+random(10)) do
begin
case random(36) of
0:Spam := Spam +'0';
1:Spam := Spam +'a';
2:Spam := Spam +'b';
3:Spam := Spam +'c';
4:Spam := Spam +'d';
5:Spam := Spam +'e';
6:Spam := Spam +'f';
7:Spam := Spam +'g';
8:Spam := Spam +'h';
9:Spam := Spam +'i';
10:Spam := Spam +'j';
11:Spam := Spam +'k';
12:Spam := Spam +'l';
13:Spam := Spam +'m';
14:Spam := Spam +'n';
15:Spam := Spam +'o';
16:Spam := Spam +'p';
17:Spam := Spam +'q';
18:Spam := Spam +'r';
19:Spam := Spam +'s';
20:Spam := Spam +'t';
21:Spam := Spam +'u';
22:Spam := Spam +'v';
23:Spam := Spam +'w';
24:Spam := Spam +'x';
25:Spam := Spam +'y';
26:Spam := Spam +'z';
27:Spam := Spam +'1';
28:Spam := Spam +'2';
29:Spam := Spam +'3';
30:Spam := Spam +'4';
31:Spam := Spam +'5';
32:Spam := Spam +'6';
33:Spam := Spam +'7';
34:Spam := Spam +'8';
35:Spam := Spam +'9';
end;
end;
writeln(Spam);
end;
Just a random string generator from my Air Runner. This can be used for anti-ban and for creating good, safe passwords. I have yet to test it, and it was cut out of a lot of other random sayings, so I don't know for sure if it will compile. Feel free to use so long as you credit me.

Naum
12-09-2007, 09:58 AM
Yes could be good for passwords. you might need to make sure the person looks in the debug box before the person deletes it :p

danrox2004
12-09-2007, 10:24 AM
You could also do something like this:
for p :+ 0 to 2 + random(10) do
begin
i := random(36);
if(i <= 9) then
begin
spam := spam + intToStr(i);
end else
begin
spam := spam + chr(i + 55);
end;
end;

Santa_Clause
12-09-2007, 12:02 PM
That won't work Jack...

If you don't set the string, then it's automatically:

''

So basically...this would just type a random letter, which could be done in a for/to/do loop...I think...

n3ss3s
12-09-2007, 12:09 PM
Hope you learn something people:


Function RandomString(sLength: Integer): String;
Var
Let: String;
I: Integer;
Begin
Let := 'abcdefghijklmnopqrstuvwxyzåäö0123456789';
For I := 0 To sLength Do
Result := Result + Let[Random(Length(Let))];
End;

Santa_Clause
12-09-2007, 12:33 PM
Read my previous post n3ss3s :p

n3ss3s
12-09-2007, 01:19 PM
Did I misunderstood or..?


program New;
Var
A: String;
begin
A := '';
Writeln(A);
end.


Empty space it gives.

fORCE_wORKS
12-09-2007, 01:42 PM
This is how its done booh-ya.

program RandomWord;

var
RandomWord: String;

begin
Repeat
insert(Chr(RandomRange(97,122)),RandomWord,(Length (RandomWord)+1));
until(Length(RandomWord) > (RandomRange(5,10)));
writeln(RandomWord);
end.

or if you want a list of words to choose from.

program RandomWord;

var
RandomWord: String;
i: Integer;

begin
repeat
Inc(i);
Repeat
insert(Chr(RandomRange(97,122)),RandomWord,(Length (RandomWord)+1));
until(Length(RandomWord) > (RandomRange(5,10)));
writeln(RandomWord);
delete(RandomWord,1,Length(RandomWord));
until(i > 20);
end.

n3ss3s
12-09-2007, 02:46 PM
Why would you want to insert a random char in a random position?

You can just go from start to end, and it will do the same thing.

R0b0t1
12-09-2007, 04:27 PM
Sorry to tell you people, but SCAR's "random" numbers are predictable :)

n3ss3s
12-09-2007, 05:39 PM
Yup,


Writeln(IntToStr(Random(5)));
ClearDebug; // Bwuahahahaa! EVIL HAX! >:)
Writeln(IntToStr(1));


mind sharing your knowledge, r0b0t?

Jackrawl
12-09-2007, 05:40 PM
OK, why would this not work?
procedure RandomStringGenerator;
var
P : Integer;
Spam : String;
begin
for P := 0 to (2+random(10)) do
case random(36) of
0:Spam := Spam +'0';
1:Spam := Spam +'a';
2:Spam := Spam +'b';
3:Spam := Spam +'c';
4:Spam := Spam +'d';
5:Spam := Spam +'e';
6:Spam := Spam +'f';
7:Spam := Spam +'g';
8:Spam := Spam +'h';
9:Spam := Spam +'i';
10:Spam := Spam +'j';
11:Spam := Spam +'k';
12:Spam := Spam +'l';
13:Spam := Spam +'m';
14:Spam := Spam +'n';
15:Spam := Spam +'o';
16:Spam := Spam +'p';
17:Spam := Spam +'q';
18:Spam := Spam +'r';
19:Spam := Spam +'s';
20:Spam := Spam +'t';
21:Spam := Spam +'u';
22:Spam := Spam +'v';
23:Spam := Spam +'w';
24:Spam := Spam +'x';
25:Spam := Spam +'y';
26:Spam := Spam +'z';
27:Spam := Spam +'1';
28:Spam := Spam +'2';
29:Spam := Spam +'3';
30:Spam := Spam +'4';
31:Spam := Spam +'5';
32:Spam := Spam +'6';
33:Spam := Spam +'7';
34:Spam := Spam +'8';
35:Spam := Spam +'9';
end;
writeln(Spam);
end;
I've run this through and it compiles.
Santa, you're wrong.
Force_work's does, and it's pretty awesome.
N3ss's has an out of range error.
Program new;
Function RandomString(sLength: Integer): String;
Var
Let: String;
I: Integer;
Begin
Let := 'abcdefghijklmnopqrstuvwxyzåäö0123456789';
For I := 0 To sLength Do
Result := Result + Let[Random(Length(Let))];
End;
begin
RandomString(11);
end.

n3ss3s
12-09-2007, 05:42 PM
It does work, but we are trying to show you more advanced ways.

R0b0t1
12-09-2007, 05:49 PM
Or less code ways...

But, anyway, if you used the Random function enough, you would find a pattern.

Jackrawl
12-09-2007, 05:55 PM
I can't say that I've seen the insert function before.
Are you saying it operates on squares, and when it passes the maximum range, it subtracts from itself?
Ex.
x = x*x+1

King of Knives
12-09-2007, 07:01 PM
N3ss's has an out of range error.
ROFL, get used to it, lol :p

@n3s: *Cough!* Edgeville Yew Cutter Version 1.0 *Cough!*

And n3s did the same as you, Jack, when he was new :D
He made a script called "Ultima Password Creator" :p
He used a gigantic Case-statement, and here he just copy-pasted Freddy's response to the script :p I remember old things, lol :D

EDIT: Did anyone say overuse of smileys?

-Knives

Santa_Clause
12-10-2007, 03:33 AM
N3ss3s is getting you out of range because an Array of Char starts from 1, not 0. It should be:

Program new;
Function RandomString(sLength: Integer): String;
Var
Let: String;
I: Integer;
Begin
Let := 'abcdefghijklmnopqrstuvwxyzåäö0123456789';
For I := 1 To sLength Do
Result := Result + Let[Random(Length(Let))];
End;
begin
RandomString(11);
end.

And Jack, I didn't say yours wouldn't compile...but why the hell would you just have a bunch of random letters? I was assuming you'd have a 'base' word to start off with, and then you added a few random letters.

So much for constructive criticism:


Santa, you're wrong.

Narcle
12-10-2007, 03:45 AM
0 is included in random() so you still get a error once in awhile so you have to do:
Function RandomString(sLength: Integer): String;
Var
Let: String;
I: Integer;
Begin
Let := 'abcdefghijklmnopqrstuvwxyz0123456789';
For I := 1 To sLength Do
Result := Result + Let[Random(Length(Let))+1];
End;

begin
writeln(RandomString(11));
end.

fORCE_wORKS
12-10-2007, 06:44 AM
Why would you want to insert a random char in a random position?

You can just go from start to end, and it will do the same thing.

take a closer look at my code it insert's a random char at the end of the string not a random position.

Boreas
12-10-2007, 06:53 AM
Sorry to tell you people, but SCAR's "random" numbers are predictable :)

Random() is not truly random, but you nor any human would be able to predict it, and more importantly, neither can jagex. So it is a random as we need it to be, and as far as we can tell, and for most people/me, that is close enough to omit the extra 6 letters (pseudo).

Santa_Clause
12-10-2007, 07:19 AM
I understand now...Jack has 2 accounts at SRL...which isn't allowed.

n3ss3s
12-10-2007, 02:26 PM
N3ss3s is getting you out of range because an Array of Char starts from 1, not 0. It should be:

Oh crap, TNotArrayOfChars are taking me over! :p

Join us... Join us...

Knives were you here back then?

Or just saw the thread and expected I was new back then?

Anyhow, thanks freddy xD


Umm why do you think Jack has two accs?

King of Knives
12-10-2007, 03:31 PM
Knives were you here back then?
Yes, I had another account with a ridiculous name... I was here for the scripts at the time... A leecher as we all started. I was looking through random scripts and saw yours on page 5 or something (I was bored).

I got interested in SCAR and wanted a fresh start (Equals a new account), so I asked WT-Fakawi to remove my account (the one with the ridiculous name). But he denied (As I could just have been a hacker), so I just made this one. I've been happy ever since :D

-Knives

n3ss3s
12-10-2007, 03:40 PM
Okay, we should get back on topic, but umm whats the danger in deleting a hackers account from a request?

Jackrawl
12-10-2007, 09:45 PM
N3ss3s is getting you out of range because an Array of Char starts from 1, not 0. It should be:

Program new;
Function RandomString(sLength: Integer): String;
Var
Let: String;
I: Integer;
Begin
Let := 'abcdefghijklmnopqrstuvwxyzåäö0123456789';
For I := 1 To sLength Do
Result := Result + Let[Random(Length(Let))];
End;
begin
RandomString(11);
end.

And Jack, I didn't say yours wouldn't compile...but why the hell would you just have a bunch of random letters? I was assuming you'd have a 'base' word to start off with, and then you added a few random letters.

So much for constructive criticism:
You said mine didn't work, I wasn't attacking you.
The point of this is to randomly generate passwords or create the illusion of an extremely frustrated autoer that isn't autoing.

Santa_Clause
12-10-2007, 10:37 PM
Oh crap, TNotArrayOfChars are taking me over! :p

Join us... Join us...

Knives were you here back then?

Or just saw the thread and expected I was new back then?

Anyhow, thanks freddy xD


Umm why do you think Jack has two accs?

My bad, my bad...I misunderstood something.

R0b0t1
12-10-2007, 10:43 PM
Ok, just for you boreas, I will dump a bunch of random words to a file... And search them...

fORCE_wORKS
12-11-2007, 02:58 AM
Random() is not truly random, but you nor any human would be able to predict it, and more importantly, neither can jagex. So it is a random as we need it to be, and as far as we can tell, and for most people/me, that is close enough to omit the extra 6 letters (pseudo).

true that, Boreas.

if anyone can find this pattern you should be playing the slots.

Jackrawl
12-11-2007, 03:29 AM
So nothing a computer can do is random..?

Boreas
12-11-2007, 05:31 AM
Nor is anything truly flat, because one atom has to be higher than the others right? But you still call a table flat.

A G E N T
12-12-2007, 12:54 AM
Nor is anything truly flat, because one atom has to be higher than the others right?

Ah, but according to Heisenberg's Uncertainty Principle we can't know that for sure, can we? :P

Maybe by some freak quantum accident, all the energy levels of each atom in each molecule on your table simultaenously flattened and stayed flat, defying all the laws of physics as we know them? Muaha.


Back on topic, some "Random" systems measure heat/sound/vibration fluctuations from hardware inside the computer (GPU, etc) and derive values from that. But that's still not a "true" random number.