1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 23:58:48 +00:00

🗑 Remove SecureString methods

Resolves #16
This commit is contained in:
Oliver Booth 2021-01-16 13:21:28 +00:00
parent 568f272c34
commit 13bd4b7fe1

View File

@ -369,50 +369,6 @@
}
}
/// <summary>
/// Converts a <see cref="string" /> to a <see cref="SecureString" />.
/// </summary>
/// <param name="str">The string to convert.</param>
/// <returns>Returns a <see cref="SecureString" />.</returns>
/// <exception cref="ArgumentNullException"><paramref name="str" /> is <see langword="null" />.</exception>
public static SecureString ToSecureString(this string str)
{
if (str is null)
{
throw new ArgumentNullException(nameof(str));
}
if (string.IsNullOrWhiteSpace(str))
{
return null;
}
var result = new SecureString();
foreach (var c in str)
{
result.AppendChar(c);
}
return result;
}
/// <summary>
/// Converts a <see cref="SecureString" /> to a <see cref="string" />.
/// </summary>
/// <param name="str">The <see cref="SecureString" /> to convert.</param>
/// <param name="extension">Whether or not to use this extension method.</param>
/// <returns>Returns a <see cref="string" />.</returns>
/// <exception cref="ArgumentNullException"><paramref name="str" /> is <see langword="null" />.</exception>
public static string ToString(this SecureString str, bool extension)
{
if (str is null)
{
throw new ArgumentNullException(nameof(str));
}
return extension ? new NetworkCredential(string.Empty, str).Password : str.ToString();
}
/// <summary>
/// Parses a shorthand time span string (e.g. 3w 2d 1.5h) and converts it to an instance of
/// <see cref="TimeSpan" />.