password generator

Run Settings
LanguageGroovy
Language Version
Run Command
import java.security.SecureRandom import groovy.transform.Field println generatePassword(15) @Field final def REGULAR_PASSWORD_CHARACTERS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' @Field final def PASSWORD_CHARACTERS = REGULAR_PASSWORD_CHARACTERS + '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ ' /** * Generates a random password in ASCII characters. * * @param length the password-length to specify * @return the password-<code>String</code> * @throws IllegalArgumentException if length is < 0 */ def generatePassword(length) { if (length < 0) throw new IllegalArgumentException("length($length) is < 0") def secureRandom = new SecureRandom() (0..<length) .collect { REGULAR_PASSWORD_CHARACTERS[secureRandom.nextInt(REGULAR_PASSWORD_CHARACTERS.length())] } .join '' }
Editor Settings
Theme
Key bindings
Full width
Lines