Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Random String

Reply
Thread Tools

Random String

 
 
Kent
Guest
Posts: n/a
 
      10-27-2005
What am I missing here. Why doesn't this produce a random string. It is
kind of random.

<%
Const ConstantLower = "bcdfghjklmnpqrstvwxyz"
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,TmpVal,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

 
Reply With Quote
 
 
 
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      10-28-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> What am I missing here. Why doesn't this produce a random string. It is
> kind of random.
>
> <%
> Const ConstantLower = "bcdfghjklmnpqrstvwxyz"
> 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,TmpVal,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
>



 
Reply With Quote
 
 
 
 
Gottfried Mayer
Guest
Posts: n/a
 
      10-28-2005
Kent wrote:
> What am I missing here. Why doesn't this produce a random string. It is
> kind of random.
>
> <%
> Const ConstantLower = "bcdfghjklmnpqrstvwxyz"
> 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,TmpVal,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:
6kD6qnbw6EJS68rjbPr6S25u3f54c7UrRS0D3uU6f1V8482s3U KN3e0B8CgrPN308VD4PKp4L0dF24L10wMl6NsJKYs0iUQoO0R0 PpQKrAkr4OJ7G1d6XpSC01ksl7WN
6kD6qnbw6EJS68rjbPr6S25u3f54c7UrRS0D3uU6f1V8482s3U KN3e0B8CgrPN308VD4PKp4L0dF24L10wMl6NsJKYs0iUQoO0R0 PpQKrAkr4OJ7G1d6XpSC01ksl7WN
6kD6qnbw6EJS68rjbPr6S25u3f54c7UrRS0D3uU6f1V8482s3U KN3e0B8CgrPN308VD4PKp4L0dF24L10wMl6NsJKYs0iUQoO0R0 PpQKrAkr4OJ7G1d6XpSC01ksl7WN
6kD6qnbw6EJS68rjbPr6S25u3f54c7UrRS0D3uU6f1V8482s3U KN3e0B8CgrPN308VD4PKp4L0dF24L10wMl6NsJKYs0iUQoO0R0 PpQKrAkr4OJ7G1d6XpSC01ksl7WN
6kD6qnbw6EJS68rjbPr6S25u3f54c7UrRS0D3uU6f1V8482s3U KN3e0B8CgrPN308VD4PKp4L0dF24L10wMl6NsJKYs0iUQoO0R0 PpQKrAkr4OJ7G1d6XpSC01ksl7WN
6kD6qnbw6EJS68rjbPr6S25u3f54c7UrRS0D3uU6f1V8482s3U KN3e0B8CgrPN308VD4PKp4L0dF24L10wMl6NsJKYs0iUQoO0R0 PpQKrAkr4OJ7G1d6XpSC01ksl7WN
6kD6qnbw6EJS68rjbPr6S25u3f54c7UrRS0D3uU6f1V8482s3U KN3e0B8CgrPN308VD4PKp4L0dF24L10wMl6NsJKYs0iUQoO0R0 PpQKrAkr4OJ7G1d6XpSC01ksl7WN
6kD6qnbw6EJS68rjbPr6S25u3f54c7UrRS0D3uU6f1V8482s3U KN3e0B8CgrPN308VD4PKp4L0dF24L10wMl6NsJKYs0iUQoO0R0 PpQKrAkr4OJ7G1d6XpSC01ksl7WN
6kD6qnbw6EJS68rjbPr6S25u3f54c7UrRS0D3uU6f1V8482s3U KN3e0B8CgrPN308VD4PKp4L0dF24L10wMl6NsJKYs0iUQoO0R0 PpQKrAkr4OJ7G1d6XpSC01ksl7WN
6kD6qnbw6EJS68rjbPr6S25u3f54c7UrRS0D3uU6f1V8482s3U KN3e0B8CgrPN308VD4PKp4L0dF24L10wMl6NsJKYs0iUQoO0R0 PpQKrAkr4OJ7G1d6XpSC01ksl7WN
3WeVJQXrONETsAMfJ0N8jp4YkBt155e3R1q48kuE34GFJ5EhA2 VywadwI8xN87UL223a0lrQ8205am3kAHMCB77x06AclO1r1jMS 7c7i4F8iYC3UOnr403XIAuga3bl3
3WeVJQXrONETsAMfJ0N8jp4YkBt155e3R1q48kuE34GFJ5EhA2 VywadwI8xN87UL223a0lrQ8205am3kAHMCB77x06AclO1r1jMS 7c7i4F8iYC3UOnr403XIAuga3bl3
3WeVJQXrONETsAMfJ0N8jp4YkBt155e3R1q48kuE34GFJ5EhA2 VywadwI8xN87UL223a0lrQ8205am3kAHMCB77x06AclO1r1jMS 7c7i4F8iYC3UOnr403XIAuga3bl3
3WeVJQXrONETsAMfJ0N8jp4YkBt155e3R1q48kuE34GFJ5EhA2 VywadwI8xN87UL223a0lrQ8205am3kAHMCB77x06AclO1r1jMS 7c7i4F8iYC3UOnr403XIAuga3bl3
3WeVJQXrONETsAMfJ0N8jp4YkBt155e3R1q48kuE34GFJ5EhA2 VywadwI8xN87UL223a0lrQ8205am3kAHMCB77x06AclO1r1jMS 7c7i4F8iYC3UOnr403XIAuga3bl3
3WeVJQXrONETsAMfJ0N8jp4YkBt155e3R1q48kuE34GFJ5EhA2 VywadwI8xN87UL223a0lrQ8205am3kAHMCB77x06AclO1r1jMS 7c7i4F8iYC3UOnr403XIAuga3bl3
3WeVJQXrONETsAMfJ0N8jp4YkBt155e3R1q48kuE34GFJ5EhA2 VywadwI8xN87UL223a0lrQ8205am3kAHMCB77x06AclO1r1jMS 7c7i4F8iYC3UOnr403XIAuga3bl3
3WeVJQXrONETsAMfJ0N8jp4YkBt155e3R1q48kuE34GFJ5EhA2 VywadwI8xN87UL223a0lrQ8205am3kAHMCB77x06AclO1r1jMS 7c7i4F8iYC3UOnr403XIAuga3bl3
3WeVJQXrONETsAMfJ0N8jp4YkBt155e3R1q48kuE34GFJ5EhA2 VywadwI8xN87UL223a0lrQ8205am3kAHMCB77x06AclO1r1jMS 7c7i4F8iYC3UOnr403XIAuga3bl3
811Scv20MFXevtTeT4JBD1yuPI8Gff03WqKU6h44V3vBo06Fat mN62860J81QDCJA8Xuwb580jmXhQhho08CY6YrlkV0go6No28y TK0OE4FC3xQQ6maybAJbXR8MhTj1
811Scv20MFXevtTeT4JBD1yuPI8Gff03WqKU6h44V3vBo06Fat mN62860J81QDCJA8Xuwb580jmXhQhho08CY6YrlkV0go6No28y TK0OE4FC3xQQ6maybAJbXR8MhTj1

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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
Random "The IListSource does not contain any datasources" and more (Crashing a live site at random, twice a week or so) Lars-Erik Aabech ASP .Net 8 04-28-2005 07:52 AM
Random not really random... Maziar Aflatoun ASP .Net 4 08-05-2004 01:26 AM
Random NOt random? Darren Clark ASP .Net 3 06-24-2004 05:23 PM



Advertisments