Skip to content

Commit 67ca878

Browse files
committed
Add Prefix/Suffix Random Word salt position options, closes #38
1 parent da295fc commit 67ca878

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

Diceware.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,14 @@ private static void ApplySalt(string[] words, SaltType salt, IEnumerable<SaltSou
294294

295295
words[targetIndex] = $"{words[targetIndex]}{separator}{singleSalt}";
296296
break;
297+
case SaltType.SuffixToRandomWord:
298+
int suffixToIndex = random.AtMost(words.Length - 1);
299+
words[suffixToIndex] = $"{words[suffixToIndex]}{singleSalt}";
300+
break;
301+
case SaltType.PrefixToRandomWord:
302+
int prefixToIndex = random.AtMost(words.Length - 1);
303+
words[prefixToIndex] = $"{singleSalt}{words[prefixToIndex]}";
304+
break;
297305
default:
298306
throw new ArgumentOutOfRangeException(nameof(salt));
299307
}

SaltType.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,9 @@ public enum SaltType
3636
BetweenOne,
3737
[Description("Between each word")]
3838
BetweenEach,
39+
[Description("Prepend to the beginning of a random word")]
40+
PrefixToRandomWord,
41+
[Description("Appended to the end of a random word")]
42+
SuffixToRandomWord,
3943
}
4044
}

0 commit comments

Comments
 (0)