diceware: switch to buildString
lambda
This commit is contained in:
parent
0830499c6c
commit
95075bd1d0
1 changed files with 5 additions and 8 deletions
|
@ -23,15 +23,12 @@ constructor(
|
||||||
|
|
||||||
/** Generates a passphrase with [wordCount] words. */
|
/** Generates a passphrase with [wordCount] words. */
|
||||||
public fun generatePassphrase(wordCount: Int, separator: Char): String {
|
public fun generatePassphrase(wordCount: Int, separator: Char): String {
|
||||||
return StringBuilder()
|
return buildString {
|
||||||
.apply {
|
|
||||||
repeat(wordCount) { idx ->
|
repeat(wordCount) { idx ->
|
||||||
append(wordMap[die.rollMultiple(DIGITS)])
|
append(wordMap[die.rollMultiple(DIGITS)])
|
||||||
if (idx < wordCount - 1) append(separator)
|
if (idx < wordCount - 1) append(separator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.toString()
|
|
||||||
.trimEnd()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
|
|
Loading…
Reference in a new issue