Skip to content

Commit 9a63e01

Browse files
committed
feat: add comments for ConvertKeysToBytes
1 parent c378553 commit 9a63e01

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/Helpers/Converters.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,18 @@ public static string ConvertToHexString(this string input)
5656
return hexBuilder.ToString();
5757
}
5858

59-
public static byte[] ConvertKeysToBytes(this string data)
59+
/// <summary>
60+
/// Converts a string to bytes and validates the resulting byte array.
61+
/// </summary>
62+
/// <param name="input">The input string to convert.</param>
63+
/// <returns>The byte array representation of the input string if valid; otherwise, null.</returns>
64+
public static byte[] ConvertKeysToBytes(this string input)
6065
{
61-
return Encoding.UTF8.GetBytes(data);
62-
}
66+
if (string.IsNullOrEmpty(input))
67+
{
68+
return null;
69+
}
70+
return Encoding.UTF8.GetBytes(input);
71+
}
6372
}
6473
}

0 commit comments

Comments
 (0)