Simple Password Generator tries to be a simple library to include in your project if you just want some quick password generation.
This library is available at Maven Central. You might need to include it in your repositories:
repositories {
mavenCentral()
}
You can then add it as a dependency to your project:
dependencies {
implementation("br.com.colman:simple-password-generator:VERSION")
}
PasswordGenerator.Default.generate() // Gives you a 8 character string with a number and a special character
PassphraseGenerator.Default.generate() // Gives you a 3 random words string separated by a hyphen, including a number
All pieces of this api have sensible defaults. You might not like them, and thus want to customize them.
val customPassphraseGenerator = PassphraseGenerator(
random = MyCustomRandomSource(), // Defaults to SecureRandom
wordGenerator = MyCustomWordGenerator {} // Defaults to words from Big F Word List
)
val randomPassphrase: String = customPassphraseGenerator.generate(
wordAmount = 5, // Defaults to 3
separator = "&", // Defaults to "-"
includeNumber = false, // Defaults to true
titleCaseWords = false, // Defaults to true
)
val customPasswordGenerator = PasswordGenerator(
random = MyCustomRandomSource(), // Defaults to SecureRandom
normalCharacters = listOf('x', 'y', 'z'), // Defaults to A-Z and a-z
numericCharacters = listOf('1', '2', '3'), // Defaults to 0-9
specialCharacters = listOf('$', '/') // Defaults to @%+\/'!#$^?:,(){?[]~`-_.
)
val randomPassword: String = customPasswordGenerator.generate(
size = 12, // Defaults to 8
includeSpecial = false, // Defaults to true
includeNumber = false, // Defaults to true
)