@@ -5,14 +5,14 @@ namespace Bit.Core.Utilities;
5
5
public static class EnumerationProtectionHelpers
6
6
{
7
7
/// <summary>
8
- /// Use this method to get a consistent int result based on the salt that is in the range.
9
- /// The same salt will always return the same index result based on range input.
8
+ /// Use this method to get a consistent int result based on the inputString that is in the range.
9
+ /// The same inputString will always return the same index result based on range input.
10
10
/// </summary>
11
11
/// <param name="hmacKey">Key used to derive the HMAC hash. Use a different key for each usage for optimal security</param>
12
- /// <param name="salt ">The string to derive an index result</param>
12
+ /// <param name="inputString ">The string to derive an index result</param>
13
13
/// <param name="range">The range of possible index values</param>
14
- /// <returns>An int between 0 and range</returns>
15
- public static int GetIndexForSaltHash ( byte [ ] hmacKey , string salt , int range )
14
+ /// <returns>An int between 0 and range - 1 </returns>
15
+ public static int GetIndexForSaltHash ( byte [ ] hmacKey , string inputString , int range )
16
16
{
17
17
if ( hmacKey == null || range <= 0 || hmacKey . Length == 0 )
18
18
{
@@ -21,7 +21,7 @@ public static int GetIndexForSaltHash(byte[] hmacKey, string salt, int range)
21
21
else
22
22
{
23
23
// Compute the HMAC hash of the salt
24
- var hmacMessage = Encoding . UTF8 . GetBytes ( salt . Trim ( ) . ToLowerInvariant ( ) ) ;
24
+ var hmacMessage = Encoding . UTF8 . GetBytes ( inputString . Trim ( ) . ToLowerInvariant ( ) ) ;
25
25
using var hmac = new System . Security . Cryptography . HMACSHA256 ( hmacKey ) ;
26
26
var hmacHash = hmac . ComputeHash ( hmacMessage ) ;
27
27
// Convert the hash to a number
0 commit comments