diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2021-12-21 17:21:54 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2021-12-21 17:22:37 +0530 |
commit | 95075bd1d080f201cc237a542822de2661f3f242 (patch) | |
tree | 241f2f86826cb24465ebad1ebe0a44ef38a5f0fa /passgen | |
parent | 0830499c6c2a027fc1313045f364e1d4a10e8539 (diff) |
diceware: switch to `buildString` lambda
Diffstat (limited to 'passgen')
-rw-r--r-- | passgen/diceware/src/main/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGenerator.kt | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/passgen/diceware/src/main/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGenerator.kt b/passgen/diceware/src/main/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGenerator.kt index ee18352e..62e3b97b 100644 --- a/passgen/diceware/src/main/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGenerator.kt +++ b/passgen/diceware/src/main/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGenerator.kt @@ -23,15 +23,12 @@ constructor( /** Generates a passphrase with [wordCount] words. */ public fun generatePassphrase(wordCount: Int, separator: Char): String { - return StringBuilder() - .apply { - repeat(wordCount) { idx -> - append(wordMap[die.rollMultiple(DIGITS)]) - if (idx < wordCount - 1) append(separator) - } + return buildString { + repeat(wordCount) { idx -> + append(wordMap[die.rollMultiple(DIGITS)]) + if (idx < wordCount - 1) append(separator) } - .toString() - .trimEnd() + } } private companion object { |