 bff21ead95
			
		
	
	bff21ead95
	
	
	
		
			
			* some groups stuff * further groups rework * fixes for pause changes * adjsut timeout interval * fixes and namespace change to file scoped * more fixes * further implement groups * fix change group ownership * add some more stuff for groups * more fixes and additions * some fixes based on analyzers, add shard info to ui * add discord command, cleanup * fix regex * add group migration and deletion on user deletion * add api method for client to check health of connection * adjust regex for vanity * fixes for server and bot * fixes some string comparison in linq queries * fixes group leave and sets alias to null * fix syntax in changeownership * add better logging, fixes for group leaving * fixes for group leave Co-authored-by: Stanley Dimant <root.darkarchon@outlook.com>
		
			
				
	
	
		
			32 lines
		
	
	
		
			982 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			982 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Security.Cryptography;
 | |
| using System.Text;
 | |
| 
 | |
| namespace MareSynchronosShared.Utils;
 | |
| 
 | |
| public static class StringUtils
 | |
| {
 | |
|     public static string GenerateRandomString(int length, string? allowableChars = null)
 | |
|     {
 | |
|         if (string.IsNullOrEmpty(allowableChars))
 | |
|             allowableChars = @"ABCDEFGHJKLMNPQRSTUVWXYZ0123456789";
 | |
| 
 | |
|         // Generate random data
 | |
|         var rnd = RandomNumberGenerator.GetBytes(length);
 | |
| 
 | |
|         // Generate the output string
 | |
|         var allowable = allowableChars.ToCharArray();
 | |
|         var l = allowable.Length;
 | |
|         var chars = new char[length];
 | |
|         for (var i = 0; i < length; i++)
 | |
|             chars[i] = allowable[rnd[i] % l];
 | |
| 
 | |
|         return new string(chars);
 | |
|     }
 | |
| 
 | |
|     public static string Sha256String(string input)
 | |
|     {
 | |
|         using var sha256 = SHA256.Create();
 | |
|         return BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(input))).Replace("-", "", StringComparison.OrdinalIgnoreCase);
 | |
|     }
 | |
| }
 |