We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c378553 commit 9a63e01Copy full SHA for 9a63e01
1 file changed
src/Helpers/Converters.cs
@@ -56,9 +56,18 @@ public static string ConvertToHexString(this string input)
56
return hexBuilder.ToString();
57
}
58
59
- public static byte[] ConvertKeysToBytes(this string data)
+ /// <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)
65
{
- return Encoding.UTF8.GetBytes(data);
- }
66
+ if (string.IsNullOrEmpty(input))
67
+ {
68
+ return null;
69
+ }
70
+ return Encoding.UTF8.GetBytes(input);
71
72
73
0 commit comments