Page 1 of 1 1
Topic Options
#42183 - 2003-06-27 01:19 PM Generate password with only letters and numbers?
Finbom Offline
Fresh Scripter

Registered: 2003-06-27
Posts: 21
Hello there!

I'm using Bryce script to generate a password. ( http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=2;t=003592#000001 )
The problem is that the software that I need the password for is unable to handle other than letters and numbers in a password.

So Im sitting here trying to find out how to restrict the generator to this.
All I want is a password that only contain LARGE/small letters from a-z and numbers.

Can anyone help to explain how to do this?

regards, Magnus Finbom

Top
#42184 - 2003-06-27 01:31 PM Re: Generate password with only letters and numbers?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
uhm.
third topic...

anyway, for me the script you linked to just gives numbers and letters.

what else do you get?
_________________________
!

download KiXnet

Top
#42185 - 2003-06-27 02:31 PM Re: Generate password with only letters and numbers?
Finbom Offline
Fresh Scripter

Registered: 2003-06-27
Posts: 21
Hi again!

This script gives all kind of chars in the password.
Examples:

D3llg%F&Bl0
RD/`Gi.(,%0
G8i+*qWS(_0
)?A+~5l6(_0

Good passwords except for that my software cant handle thoose extra chars.

Regards, Magnus

Top
#42186 - 2003-06-27 02:36 PM Re: Generate password with only letters and numbers?
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Suggestion..

Why not change from -

random(33,126,$seed)

to be -

random(48,125,$seed)

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#42187 - 2003-06-27 02:50 PM Re: Generate password with only letters and numbers?
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
This seems to be what you are looking for -

Replace this section:
code:
		$chr = random(48,57,$seed) $seed = $seed - $seedjump
select
case $i = 1
while $chr >= 48 and $chr <=57
$chr = random(65,90,$seed) $seed = $seed + $seedjump
loop
case $i = $length
while $chr >= 48 and $chr <=57
$chr = random(97,122,$seed) $seed = $seed - $seedjump
loop
endselect

It yields the following, for example -
quote:

R44582496u
G28457516u
G28457516u
G28457516u
Z39198601i
Z39737681z
T75737681z
P63765577x
P63765577x
P63765577x
A32616235n
R14044123r
R14044172o
P33878572o
P33878572o
P33878572o
J37771612j
J37771612j
J37771612j
X68075921m
X68075921m
X68075921m
X64728080b
H94728080b
H94720770j
Q94180770j
Q94180770j
Q94132124e
N11232124e
N11232124x
A08829724x
A08829724x
A08829724c
L80578488c
L87451609n
V67451609n
V67451609n
V67456475t
L30576475t
L30576475t
T05651738p
T05651738p
T05651738p
D14433232m
D14433232m
D14433232m
Z69295712w
Z69295712b
T36479085b
T36479085b

I am sure it can be improved upon. [Big Grin]

HTH,

Kent

[ 27. June 2003, 14:52: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#42188 - 2003-06-27 02:53 PM Re: Generate password with only letters and numbers?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
This will also work, and will allow you to specify which characters to use easily.

$sTerminal characters are characters which can appear anywhere.
$sNonTerminal characters are characters which must not appear at the start or end of the password.

code:
udfPWGen(10,"Bills login") ?
udfPWGen(5,1999) ?
udfPWGen(20) ?

Function udfPWGen($iLength,Optional $sSeed)
Dim $sTerminal,$sNonTerminal,$iIndex,$iSeed

$sTerminal=$sTerminal+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
$sTerminal=$sTerminal+"abcdefghijklmnopqrstuvwxyz"
$sNonTerminal="0123456789"
For $iIndex=1 To Len($sSeed)
$iSeed=$iSeed+Asc(SubStr($sSeed,$iIndex,1))
Next
Srnd(@TICKS+$iSeed*@YEAR+@YDAYNO)
For $iIndex=1 to $iLength
$sSelectFrom=IIF($iIndex=1 OR $iIndex=$iLength,$sTerminal,$sTerminal+$sNonTerminal)
$udfPWGen=$udfPWGEn+Cstr(Substr($sSelectFrom,(Rnd(Len($sSelectFrom))+1),1))
Next
EndFunction


Top
#42189 - 2003-06-27 03:25 PM Re: Generate password with only letters and numbers?
Finbom Offline
Fresh Scripter

Registered: 2003-06-27
Posts: 21
WoW! Never seen this fast answers in a forum before. [Smile]

It works great now!

Thanks!

Top
#42190 - 2003-09-02 07:49 PM Re: Generate password with only letters and numbers?
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Some strange behavior with this script modified just a bit. Riddle me this...

This returns 8 chars as specified:

code:
udfPWGen(8,"vfewgc000v") ?

Function udfPWGen($iLength,Optional $sSeed)
Dim $sTerminal,$sNonTerminal,$iIndex,$iSeed

$sTerminal=$sTerminal+"BCDFGHJKLMNPQRSTVWXYZ"
$sTerminal=$sTerminal+"bcdfghjklmnpqrstvwxyz"
$sNonTerminal="0123456789"
For $iIndex=1 To Len($sSeed)
$iSeed=$iSeed+Asc(SubStr($sSeed,$iIndex,1))
Next
Srnd($iSeed*@monthno)
For $iIndex=1 to $iLength
$sSelectFrom=IIF($iIndex=1 OR $iIndex=$iLength,$sTerminal,$sTerminal+$sNonTerminal)
$udfPWGen=$udfPWGEn+Cstr(Substr($sSelectFrom,(Rnd(Len($sSelectFrom))+1),1))
Next
EndFunction

This also returns 8 even though I specified 9

code:
udfPWGen(9,"vfewgc000v") ?

Function udfPWGen($iLength,Optional $sSeed)
Dim $sTerminal,$sNonTerminal,$iIndex,$iSeed

$sTerminal=$sTerminal+"BCDFGHJKLMNPQRSTVWXYZ"
$sTerminal=$sTerminal+"bcdfghjklmnpqrstvwxyz"
$sNonTerminal="0123456789"
For $iIndex=1 To Len($sSeed)
$iSeed=$iSeed+Asc(SubStr($sSeed,$iIndex,1))
Next
Srnd($iSeed*@monthno)
For $iIndex=1 to $iLength
$sSelectFrom=IIF($iIndex=1 OR $iIndex=$iLength,$sTerminal,$sTerminal+$sNonTerminal)
$udfPWGen=$udfPWGEn+Cstr(Substr($sSelectFrom,(Rnd(Len($sSelectFrom))+1),1))
Next
EndFunction

This returns only 9 even though 10 specified.
code:
udfPWGen(10,"vfewgc000v") ?

Function udfPWGen($iLength,Optional $sSeed)
Dim $sTerminal,$sNonTerminal,$iIndex,$iSeed

$sTerminal=$sTerminal+"BCDFGHJKLMNPQRSTVWXYZ"
$sTerminal=$sTerminal+"bcdfghjklmnpqrstvwxyz"
$sNonTerminal="0123456789"
For $iIndex=1 To Len($sSeed)
$iSeed=$iSeed+Asc(SubStr($sSeed,$iIndex,1))
Next
Srnd($iSeed*@monthno)
For $iIndex=1 to $iLength
$sSelectFrom=IIF($iIndex=1 OR $iIndex=$iLength,$sTerminal,$sTerminal+$sNonTerminal)
$udfPWGen=$udfPWGEn+Cstr(Substr($sSelectFrom,(Rnd(Len($sSelectFrom))+1),1))
Next
EndFunction

I cannot replicate the error with any other input besides 'vfewgc000v', but this input certainly doesn't work right.
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#42191 - 2003-09-03 09:42 AM Re: Generate password with only letters and numbers?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Oops.

The problem is caused by the way I've used RND(). Normally RND(ceiling) implementations return a random number which is between 0 and ceiling-1, in other words the modulo of ceiling, or in some cases between 1 and ceiling. KiXtart returns a value between 0 and ceiling, which is a little unusual.

In the password generator UDF this would occasionally cause it to read past the end of the $sSelectFrom string, adding a blank character.

The fixed version follows:


Function udfPWGen($iLength,Optional $sSeed)
Dim $sTerminal,$sNonTerminal,$iIndex,$iSeed

$sTerminal=$sTerminal+"BCDFGHJKLMNPQRSTVWXYZ"
$sTerminal=$sTerminal+"bcdfghjklmnpqrstvwxyz"
$sNonTerminal="0123456789"
For $iIndex=1 To Len($sSeed)
$iSeed=$iSeed+Asc(SubStr($sSeed,$iIndex,1))
Next
Srnd($iSeed*@monthno)
For $iIndex=1 to $iLength
$sSelectFrom=IIF($iIndex=1 OR $iIndex=$iLength,$sTerminal,$sTerminal+$sNonTerminal)
$udfPWGen=$udfPWGEn+Cstr(Substr($sSelectFrom,(Rnd(Len($sSelectFrom)-1)+1),1))
Next
EndFunction



Serves me right for not reading the manual properly.

Top
#42192 - 2003-09-03 04:23 PM Re: Generate password with only letters and numbers?
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Ahhh. Makes sense now. I would have figured that substr would have thrown and error by trying to read beyond the bounds of its string...
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#42193 - 2004-05-07 10:38 AM Re: Generate password with only letters and numbers?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Updated again to handle non-seeded calls better.

Code:
$i=udfpwgen(5,@TIME+"initialseedvalue")
$i=10
while $i
$i " " udfpwgen(10) ?
$i=$i-1
Loop

Function udfPWGen($iLength,Optional $sSeed)
Dim $sTerminal,$sNonTerminal,$iIndex,$iSeed

$sTerminal=$sTerminal+"BCDFGHJKLMNPQRSTVWXYZ"
$sTerminal=$sTerminal+"bcdfghjklmnpqrstvwxyz"
$sNonTerminal="0123456789"
If $sSeed<>""
For $iIndex=1 To Len($sSeed)
$iSeed=$iSeed*10+Asc(SubStr($sSeed,$iIndex,1))
Next
Srnd($iSeed)
; Discard first (not very random) value
$iIndex=Rnd(0)
EndIf
For $iIndex=1 to $iLength
$sSelectFrom=IIF($iIndex=1 OR $iIndex=$iLength,$sTerminal,$sTerminal+$sNonTerminal)
$udfPWGen=$udfPWGEn+Cstr(Substr($sSelectFrom,(Rnd(Len($sSelectFrom)-1)+1),1))
Next
EndFunction



Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.063 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org