Jump to content

How do I generate a password with a user chosen length from a valuelist perhaps?


This topic is 5542 days old. Please don't post here. Open a new topic instead.

Recommended Posts

After reading Comments' suggestion on generating random 10 character passwords, I realised that might be a bit constricting, say if you wanted to generate a password with a user chosen length perhaps?

Comments' original post for the script:

http://www.fmforums.com/forum/showtopic.php?tid/194847/

What I have is two fields in the table and one button.

fieldname: PasswordLength

is linked to a valuelist that gives numbers 6 to 26 in sequence [6,7,8,9,etc]

fieldname: SitePassword

is where I want the script to output to.

button: Generate

would run the mainstay of the script.

From what I presently have:

Middle("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; Round(Random * 60; 0)+1; 1)

does the random generation for 1 character.

Could someone shed some light on how to do the script?

[i apologize for the following script in pidgin script inglish]

From what I know so far:

// set the storage areas for the script

Let a=number, b=textfield

// get the external variables

Get fieldname[PasswordLength] = a

// run the script while a is greater than zero

While a > 0

do Middle("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; Round(Random * 60; 0)+1; 1)

// put the output into one of the stores

add result to b

// reduce the count of a by 1

a = a - 1

// does a equal 0? If yes, output to SitePassword

if a = 0 then

// output b to SitePassword

set fieldname[sitePassword] = b

//if not, loop back to top

else

loop

Now I know the above doesn't work as a script yet : - but that is roughly what I'm after.

The idea being that you can choose a password length of between 6 characters [er... kind of difficult to guess] and 26 characters [whoa! we're talking MI5 then! : ]

and then have that output to the second field - whereupon it gets wrapped up into the ftp linkname that I do through a formula/calculation.

Suggestions would be helpful. Or maybe someone can point me to an already covered topic that they have found on their travels?

Chris

Link to comment
Share on other sites

To generate a random string of given length, you need either a looping script or a custom function. Either one is rather trivial; the script, for example, could be:

Loop

Exit Loop If [ Length ( $password ) ≥ Table::PasswordLength ]

Set Variable [ $password ; $password & Middle ( "0123...XYZ" ; Ceiling ( Random * 62 ) ; 1 )

End Loop

Set Field [ Table::Password ; $password ]

BTW, rounding the result of the Random function is not a good idea, because it skews the distribution away from uniform.

Edited by Guest
added the script
Link to comment
Share on other sites

This topic is 5542 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.