1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-14 04:35:41 +00:00

(#42) throw on null value for string.Base64*code

This commit is contained in:
Oliver Booth 2022-03-06 17:29:26 +00:00
parent 3e11a209e7
commit c151a9c754
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634

View File

@ -42,8 +42,14 @@ public static class StringExtensions
/// </summary> /// </summary>
/// <param name="value">The base-64 string to convert.</param> /// <param name="value">The base-64 string to convert.</param>
/// <returns>The plain text string representation of <paramref name="value" />.</returns> /// <returns>The plain text string representation of <paramref name="value" />.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
public static string Base64Decode(this string value) public static string Base64Decode(this string value)
{ {
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
return Convert.FromBase64String(value).ToString(Encoding.ASCII); return Convert.FromBase64String(value).ToString(Encoding.ASCII);
} }
@ -52,8 +58,14 @@ public static class StringExtensions
/// </summary> /// </summary>
/// <param name="value">The plain text string to convert.</param> /// <param name="value">The plain text string to convert.</param>
/// <returns>The string representation, in base 64, of <paramref name="value" />.</returns> /// <returns>The string representation, in base 64, of <paramref name="value" />.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
public static string Base64Encode(this string value) public static string Base64Encode(this string value)
{ {
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
return Convert.ToBase64String(value.GetBytes(Encoding.ASCII)); return Convert.ToBase64String(value.GetBytes(Encoding.ASCII));
} }