Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Jan 27, 2025
1 parent dd37914 commit 0a2ce30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions ArchiSteamFarm/Core/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ public static IEnumerable<T> AsLinqThreadSafeEnumerable<T>(this ICollection<T> c
return collection.Select(static entry => entry);
}

[PublicAPI]
public static string AsMasked(this string text, char mask = '*') {
ArgumentNullException.ThrowIfNull(text);

return new string(mask, text.Length);
}

[PublicAPI]
public static string GenerateChecksumFor(byte[] source) {
ArgumentNullException.ThrowIfNull(source);
Expand Down
8 changes: 4 additions & 4 deletions ArchiSteamFarm/NLog/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ internal static void EnableTraceLogging() {
Console.Write(cryptKeyText);
result = ConsoleReadLineMasked();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(new string('*', result.Length)));
ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(result.AsMasked()));

break;
case ASF.EUserInputType.DeviceConfirmation:
Expand Down Expand Up @@ -145,7 +145,7 @@ internal static void EnableTraceLogging() {
Console.Write(passwordText);
result = ConsoleReadLineMasked();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(new string('*', result.Length)));
ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(result.AsMasked()));

break;
case ASF.EUserInputType.SteamGuard:
Expand All @@ -167,7 +167,7 @@ internal static void EnableTraceLogging() {
Console.Write(steamParentalCodeText);
result = ConsoleReadLineMasked();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(new string('*', result.Length)));
ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(result.AsMasked()));

break;
case ASF.EUserInputType.TwoFactorAuthentication:
Expand All @@ -178,7 +178,7 @@ internal static void EnableTraceLogging() {
Console.Write(twoFactorAuthenticationText);
result = ConsoleReadLine();

ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(new string('*', result?.Length ?? 0)));
ASF.ArchiLogger.LogGenericInfo(Strings.FormatInput(result?.AsMasked()));

break;
default:
Expand Down

0 comments on commit 0a2ce30

Please sign in to comment.