/** My first Scala-application*/
object Main extends App {
println("Hello World!")
println(new PasswordGenerator() generatePassword(50))
}
import scala.language.postfixOps
import java.security.SecureRandom
/**
* A password generator using a standard Java-library
*/
class PasswordGenerator {
// Declaration
val algorithm = new SecureRandom
val passwordChars = "0123456789*-+/#'{[}]?!:;%$~_ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" toCharArray
// Methods
def generatePassword(length: Int) = (for (i <- 0 to length) yield passwordChars(algorithm.nextInt(passwordChars length))).mkString
}