mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-29 13:27:46 +00:00
diceware: switch to buildString
lambda
This commit is contained in:
parent
0830499c6c
commit
95075bd1d0
@ -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…
x
Reference in New Issue
Block a user