sharp-chat/SharpChat/Extensions.cs

13 lines
435 B
C#

using System.Text;
namespace SharpChat {
public static class Extensions {
public static string GetIdString(this byte[] buffer) {
const string id_chars = "abcdefghijklmnopqrstuvwxyz0123456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ";
StringBuilder sb = new();
foreach(byte b in buffer)
sb.Append(id_chars[b % id_chars.Length]);
return sb.ToString();
}
}
}