Last active
September 5, 2021 09:26
-
-
Save lexuschert/35003ad944abc9a581fc66b066397005 to your computer and use it in GitHub Desktop.
Faster mask for string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Faster mask for string | |
/// Example: CreateMask("Password123") | |
/// Return: Pas******** | |
/// | |
/// https://www.youtube.com/watch?v=Kd8oNLeRc2c | |
/// | |
public static string CreateMask(string stringValue) => | |
string.Create( | |
stringValue.Length, | |
stringValue, | |
(span, value) => { | |
value.AsSpan().CopyTo(span); | |
span[3..].Fill('*') | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment