473,698 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Random String

What am I missing here. Why doesn't this produce a random string. It is
kind of random.

<%
Const ConstantLower = "bcdfghjklmnpqr stvwxyz"
Const VowelLower = "aeiou"
Const Numbers = "0123456789 "
Const NumOfChar = 12

Dim x : x = 0
Dim TmpVal
Dim TmpName
Dim y
y = 0

Do while y < 100
x = 1
TmpName = ""
TmpVal=""
Do while x <= NumOfChar
randomize
TmpVal = int(Rnd*3)
select case TmpVal
Case 0
randomize
TmpVal = int(Rnd*21)
if TmpVal = 0 then TmpVal = 1
TmpName = TmpName & mid
(ConstantLower, TmpVal,1)
Case 1
randomize
TmpVal = int(Rnd*5)
if TmpVal = 0 then TmpVal = 1
TmpName = TmpName & mid
(VowelLower,Tmp Val,1)
Case 2
randomize
TmpVal = int(Rnd*10)
if TmpVal = 0 then TmpVal = 1
TmpName = TmpName & mid
(Numbers,TmpVal ,1)
end Select
x = x + 1
loop

Response.Write TmpName & "<BR>"
y = y + 1
Loop
%>

Thanks for your help,
Kent

Oct 27 '05 #1
2 3034
What do you see? I got this output:

amcigsr110ac<BR >
e170j60q106e<BR >
eah0leob2oe8<BR >
paannj2e6px0<BR >
ivmo50bo72il<BR >
i71ar06yoa0w<BR >
vqq6txfj8di1<BR >
xka7758t0813<BR >
a0vh86kaaoy7<BR >
caeibea2ai5f<BR >
dy8a0gnsamci<BR >
gsr110ace170<BR >
j60q106eeah0<BR >
mioc3oe8iaap<BR >
pk3e6qy0ixna<BR >
rdc873ino81e<BR >
s07b8e0owis7<BR >
vyhl0fo2omex<BR >
8s0v0823a1wj<BR >
b6l1a0b7daii<BR >
ce022i6aga0a<BR >
0hqtanaiavih<BR >
1bade280k7fr<BR >
20teeaj1mioc<BR >
s07h833ooir7<BR >
coal0ao2oeef<BR >
fs0o0gp6amda<BR >
g6l1a0acaaii<BR >
je0q2i6agaha<BR >
lhqt2naiabin<BR >
42ade480e7mr<BR >
50b4eaj3mioa<BR >
6o48iaappk5e<BR >
6qfkidearkc7<BR >
75imo81es07h<BR >
04loo6t7daam<BR >
0ao2ae3ggi0o<BR >
0hq6apfej7e2<BR >
10adaaioke1r<BR >
2otaaak1mjrv<BR >
3qaiad7p4kea<BR >
e580e8nsr0c5<BR >
i3lnniaa6o40<BR >
6a0iqe647rhl<BR >
ifiaima88sip<BR >
o02ev17j04lo<BR >
iep5yodhocsa<BR >
wja0bp7i0c35<BR >
x20f0ihaaoob<BR >
aaei1ea4ar5c<BR >
cxfahdmqalbe<BR >
f8i331aba368<BR >
h6243oxeeag2<BR >
jeooeiaoebom<BR >
lg4a5m0gpbkw<BR >
n2yi64eki7aa<BR >
50i0oa1tiep5<BR >
boaj8ai1xka0<BR >
cr8i0fm5al0a<BR >
16kaaoobaaei<BR >
heapai5fdyga<BR >
kgnr2mcigbi3<BR >
31ace470j63q<BR >
40beeah3leoa<BR >
5oe8eaanmh4e<BR >
6pdhicmop2bo<BR >
75ili70ar06f<BR >
oa2woiq6boaj<BR >
h3apai5leog0<BR >
jeoy2ikenbi3<BR >
311a3478p63w<BR >
40yeeae3ieoa<BR >
5oe8ej0ttp4e<BR >
6vdhicsow2a7<BR >
75isi702y06f<BR >
7a2ooix6boei<BR >
8ei1ora0cx8i<BR >
0dm5al0e16qa<BR >
08oba14ih3ap<BR >
166eeah0leob<BR >
2oe5pbin422e<BR >
3480i7mo50b4<BR >
eai3iioaro48<BR >
ia0wvq5e6xfj<BR >
6doaxka775it<BR >
o813b0vh832o<BR >
oiy7coei0eo2<BR >
oiefdy8o0gn6<BR >
w28k04na07vx<BR >
f0ee0ao3ai4j<BR >
ao081jr7aqge<BR >
k7e220aaa3io<BR >
mi1t3owaaal1<BR >
pesw4raief7r<BR >
ql3aes00e8pv<BR >
s1a653epq6aa<BR >
7a506a1iiet5<BR >
8ijmohiaina0<BR >
yt7iob24w28k<BR >
05pa07oya0ei<BR >

Ray at work

"Kent" <un**********@m chsi.com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com...
What am I missing here. Why doesn't this produce a random string. It is
kind of random.

<%
Const ConstantLower = "bcdfghjklmnpqr stvwxyz"
Const VowelLower = "aeiou"
Const Numbers = "0123456789 "
Const NumOfChar = 12

Dim x : x = 0
Dim TmpVal
Dim TmpName
Dim y
y = 0

Do while y < 100
x = 1
TmpName = ""
TmpVal=""
Do while x <= NumOfChar
randomize
TmpVal = int(Rnd*3)
select case TmpVal
Case 0
randomize
TmpVal = int(Rnd*21)
if TmpVal = 0 then TmpVal = 1
TmpName = TmpName & mid
(ConstantLower, TmpVal,1)
Case 1
randomize
TmpVal = int(Rnd*5)
if TmpVal = 0 then TmpVal = 1
TmpName = TmpName & mid
(VowelLower,Tmp Val,1)
Case 2
randomize
TmpVal = int(Rnd*10)
if TmpVal = 0 then TmpVal = 1
TmpName = TmpName & mid
(Numbers,TmpVal ,1)
end Select
x = x + 1
loop

Response.Write TmpName & "<BR>"
y = y + 1
Loop
%>

Thanks for your help,
Kent

Oct 28 '05 #2
Kent wrote:
What am I missing here. Why doesn't this produce a random string. It is
kind of random.

<%
Const ConstantLower = "bcdfghjklmnpqr stvwxyz"
Const VowelLower = "aeiou"
Const Numbers = "0123456789 "
Const NumOfChar = 12

Dim x : x = 0
Dim TmpVal
Dim TmpName
Dim y
y = 0

Do while y < 100
x = 1
TmpName = ""
TmpVal=""
Do while x <= NumOfChar
randomize
TmpVal = int(Rnd*3)
select case TmpVal
Case 0
randomize
TmpVal = int(Rnd*21)
if TmpVal = 0 then TmpVal = 1
TmpName = TmpName & mid
(ConstantLower, TmpVal,1)
Case 1
randomize
TmpVal = int(Rnd*5)
if TmpVal = 0 then TmpVal = 1
TmpName = TmpName & mid
(VowelLower,Tmp Val,1)
Case 2
randomize
TmpVal = int(Rnd*10)
if TmpVal = 0 then TmpVal = 1
TmpName = TmpName & mid
(Numbers,TmpVal ,1)
end Select
x = x + 1
loop

Response.Write TmpName & "<BR>"
y = y + 1
Loop
%>

Thanks for your help,
Kent


Hi Kent,

The rnd function only creates quasi-random numbers:

I have seen this while playing around with a random password generator I
created.
You can try this yourself:
create strings with a length of 128 or 256 or 512 ..., then you'll see
that a number of times the exact same string will be created.
Example (with my randomPW.asp using the rnd function):

Fixed length (128 chars) Passwords:
6kD6qnbw6EJS68r jbPr6S25u3f54c7 UrRS0D3uU6f1V84 82s3UKN3e0B8Cgr PN308VD4PKp4L0d F24L10wMl6NsJKY s0iUQoO0R0PpQKr Akr4OJ7G1d6XpSC 01ksl7WN
6kD6qnbw6EJS68r jbPr6S25u3f54c7 UrRS0D3uU6f1V84 82s3UKN3e0B8Cgr PN308VD4PKp4L0d F24L10wMl6NsJKY s0iUQoO0R0PpQKr Akr4OJ7G1d6XpSC 01ksl7WN
6kD6qnbw6EJS68r jbPr6S25u3f54c7 UrRS0D3uU6f1V84 82s3UKN3e0B8Cgr PN308VD4PKp4L0d F24L10wMl6NsJKY s0iUQoO0R0PpQKr Akr4OJ7G1d6XpSC 01ksl7WN
6kD6qnbw6EJS68r jbPr6S25u3f54c7 UrRS0D3uU6f1V84 82s3UKN3e0B8Cgr PN308VD4PKp4L0d F24L10wMl6NsJKY s0iUQoO0R0PpQKr Akr4OJ7G1d6XpSC 01ksl7WN
6kD6qnbw6EJS68r jbPr6S25u3f54c7 UrRS0D3uU6f1V84 82s3UKN3e0B8Cgr PN308VD4PKp4L0d F24L10wMl6NsJKY s0iUQoO0R0PpQKr Akr4OJ7G1d6XpSC 01ksl7WN
6kD6qnbw6EJS68r jbPr6S25u3f54c7 UrRS0D3uU6f1V84 82s3UKN3e0B8Cgr PN308VD4PKp4L0d F24L10wMl6NsJKY s0iUQoO0R0PpQKr Akr4OJ7G1d6XpSC 01ksl7WN
6kD6qnbw6EJS68r jbPr6S25u3f54c7 UrRS0D3uU6f1V84 82s3UKN3e0B8Cgr PN308VD4PKp4L0d F24L10wMl6NsJKY s0iUQoO0R0PpQKr Akr4OJ7G1d6XpSC 01ksl7WN
6kD6qnbw6EJS68r jbPr6S25u3f54c7 UrRS0D3uU6f1V84 82s3UKN3e0B8Cgr PN308VD4PKp4L0d F24L10wMl6NsJKY s0iUQoO0R0PpQKr Akr4OJ7G1d6XpSC 01ksl7WN
6kD6qnbw6EJS68r jbPr6S25u3f54c7 UrRS0D3uU6f1V84 82s3UKN3e0B8Cgr PN308VD4PKp4L0d F24L10wMl6NsJKY s0iUQoO0R0PpQKr Akr4OJ7G1d6XpSC 01ksl7WN
6kD6qnbw6EJS68r jbPr6S25u3f54c7 UrRS0D3uU6f1V84 82s3UKN3e0B8Cgr PN308VD4PKp4L0d F24L10wMl6NsJKY s0iUQoO0R0PpQKr Akr4OJ7G1d6XpSC 01ksl7WN
3WeVJQXrONETsAM fJ0N8jp4YkBt155 e3R1q48kuE34GFJ 5EhA2VywadwI8xN 87UL223a0lrQ820 5am3kAHMCB77x06 AclO1r1jMS7c7i4 F8iYC3UOnr403XI Auga3bl3
3WeVJQXrONETsAM fJ0N8jp4YkBt155 e3R1q48kuE34GFJ 5EhA2VywadwI8xN 87UL223a0lrQ820 5am3kAHMCB77x06 AclO1r1jMS7c7i4 F8iYC3UOnr403XI Auga3bl3
3WeVJQXrONETsAM fJ0N8jp4YkBt155 e3R1q48kuE34GFJ 5EhA2VywadwI8xN 87UL223a0lrQ820 5am3kAHMCB77x06 AclO1r1jMS7c7i4 F8iYC3UOnr403XI Auga3bl3
3WeVJQXrONETsAM fJ0N8jp4YkBt155 e3R1q48kuE34GFJ 5EhA2VywadwI8xN 87UL223a0lrQ820 5am3kAHMCB77x06 AclO1r1jMS7c7i4 F8iYC3UOnr403XI Auga3bl3
3WeVJQXrONETsAM fJ0N8jp4YkBt155 e3R1q48kuE34GFJ 5EhA2VywadwI8xN 87UL223a0lrQ820 5am3kAHMCB77x06 AclO1r1jMS7c7i4 F8iYC3UOnr403XI Auga3bl3
3WeVJQXrONETsAM fJ0N8jp4YkBt155 e3R1q48kuE34GFJ 5EhA2VywadwI8xN 87UL223a0lrQ820 5am3kAHMCB77x06 AclO1r1jMS7c7i4 F8iYC3UOnr403XI Auga3bl3
3WeVJQXrONETsAM fJ0N8jp4YkBt155 e3R1q48kuE34GFJ 5EhA2VywadwI8xN 87UL223a0lrQ820 5am3kAHMCB77x06 AclO1r1jMS7c7i4 F8iYC3UOnr403XI Auga3bl3
3WeVJQXrONETsAM fJ0N8jp4YkBt155 e3R1q48kuE34GFJ 5EhA2VywadwI8xN 87UL223a0lrQ820 5am3kAHMCB77x06 AclO1r1jMS7c7i4 F8iYC3UOnr403XI Auga3bl3
3WeVJQXrONETsAM fJ0N8jp4YkBt155 e3R1q48kuE34GFJ 5EhA2VywadwI8xN 87UL223a0lrQ820 5am3kAHMCB77x06 AclO1r1jMS7c7i4 F8iYC3UOnr403XI Auga3bl3
811Scv20MFXevtT eT4JBD1yuPI8Gff 03WqKU6h44V3vBo 06FatmN62860J81 QDCJA8Xuwb580jm XhQhho08CY6Yrlk V0go6No28yTK0OE 4FC3xQQ6maybAJb XR8MhTj1
811Scv20MFXevtT eT4JBD1yuPI8Gff 03WqKU6h44V3vBo 06FatmN62860J81 QDCJA8Xuwb580jm XhQhho08CY6Yrlk V0go6No28yTK0OE 4FC3xQQ6maybAJb XR8MhTj1

But as I will never create 128 character passwords (the users can't even
remember 8 chars), this issue is very minor to me.
Just my 2 cents

Gottfried
Oct 28 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3699
by: Brandon Michael Moore | last post by:
I'm trying to test a web application using a tool written in python. I would like to be able to generate random values to put in fields. I would like to be able to generate random dates (in a specified range), random strings (specifying allowed characters and a distribution of lengths), or choose randomly between several generators (for better control of the distribution of values). Is there any library for this sort of thing in Python?...
21
23154
by: Andreas Lobinger | last post by:
Aloha, i wanted to ask another problem, but as i started to build an example... How to generate (memory and time)-efficient a string containing random characters? I have never worked with generators, so my solution at the moment is: import string import random random.seed(14)
3
5025
by: TaTonka | last post by:
hi! how can i manage it (html or jscript with css) that everytime a user loads or refreshes a page, the page has a new bgcolor. i want to put it in a single file, so that all my pages have the same color, but after every refresh a new random one. thanx 4 your support
10
5979
by: Johnny Snead | last post by:
Hey guys, Need help with this random sort algorithm private void cmdQuestion_Click(object sender, System.EventArgs e) { Random rnd = new Random(); //initialize rnd to new random object System.Random iRnd = new System.Random(); string theNum = iRnd.Next(0,8).ToString(); lblAnswer.Text = iRnd.Next(0,8).ToString();
6
9761
by: Maziar Aflatoun | last post by:
Hi everyone, I have the following random string generator public static string getAlphabets(int strLength) { string RandomString = ""; Random X = new Random(); for (int x=0; x < strLength; x++) RandomString +=(char)(X.Next(65, 90)); return RandomString;
4
2752
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. It should put a blue and yellow box on the page with "This is a test" as part of the picture. But what I get is a broken Gif. The other problem is that I can't view the source???? The view source is disabled for this page. What causes this?
3
2081
by: tshad | last post by:
I have a page that I am getting a username and password as a random number (2 letters, one number and 4 more letters) I have 2 functions I call: ************************************************* Function RandomString(size as integer, lowerCase as boolean) as string Dim builder as StringBuilder = new StringBuilder() Dim random as Random = new Random() Dim i as integer dim ch as char
7
2022
by: teh.sn1tch | last post by:
I created a random number generator for an application that uses a MersenneTwister class I found on the net. Basically I generate two random numbers from the MersenneTwister class and use each one as a seed for the built in Random class of the .net framework. To better illustrate I am prodviding the complete code for this application, it isn't too much but I would like to know if this is a viable solution because I am a pretty new to C#...
6
4812
by: Mike Langworthy | last post by:
i can not seem to get this code to work. someone please help using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program {
11
3020
TTCEric
by: TTCEric | last post by:
This will be original. I promise. I cannot get the random number generator to work. I tried seeding with Date.Now.Milliseconds, it still results in the same values. What I have are arrays of values. I get a random index value for each array so I can pull the data from them.
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.