object makepwd extends App {

  def newPassword( salt:String = "", length:Int = 13, strong:Boolean = true ) = {

    val saltHash = salt.hashCode & ~(1 << 31)

    import java.util.Calendar._

    val cal = java.util.Calendar.getInstance()
    val rand = new scala.util.Random((cal.getTimeInMillis+saltHash).toLong)
    val lower = ('a' to 'z').mkString
    val upper = ('A' to 'Z').mkString
    val nums = ('0' to '9').mkString
    val strongs = "!\"#$%&'()*+,-./:;<=>?@[]^_{|}~"
    val unwanted = if( strong ) "" else "0Ol"

    val pool = (lower + upper + nums + (if( strong ) strongs else "")).
               filterNot( c => unwanted.contains(c) )

    val pwdStream = Stream.continually( (for( n <- 1 to length; c = pool(rand.nextInt(pool.length) ) ) yield c).mkString )