Welcome GuestLogin

A Drunken Wiki

RSS RSS

A Drunken Wiki is the companion wiki to the blog "A Drunken Madman", written by Jason Brown.

Navigation




Search the wiki
»

Vaccination Saves Lives: Stop The Australian Vaccination Network


Find me on Twitter, Facebook, Google+, Pinterest and LinkedIn





Pin It






Alpha Archive Atheism Blue Mountains Climbing Cycling Development DotNet GPS Guitar HMHB JavaScript JQuery LINQ Meta MTB Music Perl Powershell RNP SharePoint Skepticism Social Media Training Ukulele Vaccines Visual Studio WebParts Woodford Festival 2011 XML

PoweredBy
Occasionally, one has a need to generate randomised passwords. Here's my old script which does the job. You can download the file here

Code (.WSF specific markup omitted):

use Win32::Clipboard;

#***********************************************************************
# this password generator builds a random 8-character password then
# attaches it to the windows clipboard, using PerlScript. 
# 
# (c) jason brown 2001 all rights of the author reserved
# http://wiki.mycolleaguesareidiots.com/GeneratePassword.ashx
#***********************************************************************

$cl = Win32::Clipboard();

# character space defined here. Change characters as you like
$txt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_=+";

$lengt = 8; 
# or, for random length: 
# int(rand() * 5) + 6;

$x = 0; $out = "";
while($x<$lengt)	{
  $ranNo = int(rand() * length($txt));
  $a = substr($txt, $ranNo, 1);
  $out = "$out$a"; $x++;
}

$cl->Set($out);
$WScript->echo("new password $out has been placed on the clipboard");

This would also work in a *.pl file on Windows with ActivePerl or Strawberry Perl (or similar) - if you replace the last line with a print call instead of the WScript-specific echo call. I did it as a WSF for pretty much no reason at all other than that I had new file templates handy at the time. I used them a lot because WSFs can mix languages in the same file, in differing script blocks, and I did occasionally mix snippets together, back in the day.
  Name Size
- GeneratePassword.zip 738 B

 

ScrewTurn Wiki version 3.0.5.600. Some of the icons created by FamFamFam.