Archive for February, 2009

Actionscript PasswordUtil

Hi folks,

since so many people liked the CookieUtil, I will give away one of my other utils I have – a PasswordUtil. Many of you that are developing web applications with flex, or other actionscript 3 techniques, might have been in a situation where you needed to offer your users a solution to register up for a service. But what if you wanted to give your users the possibility to let you generate a password for them – solution is easy use PasswordUtil.

It allows you to generate random passwords in actionscript 3 of any length with just one single line of code. Just give a length and the chars that should be used. The class has predefined constants that you can use for the charset.

It comes with pre selected alphabets for the different chars you might want to use for your passwords, but you can extend it with any chars you like – change some lines and you can use it in russian or any other language.

Using it is easy:

var myPassword:String = PasswordUtil.generateRandomString( 32 , PasswordUtil.LETTERS);

Just combine that with a button and a textinput field and voilá – there you go. The package contains a sample flex project that shows what you can do with it. It can also be used to generate a random integer of a specified length.

The scripts is public domain on a use it for whatever you like license, just like the CookieUtil.