sharp-chat/SharpChat/Extensions.cs

14 lines
435 B
C#
Raw Normal View History

using System.Text;
2022-08-30 15:00:58 +00:00
namespace SharpChat {
public static class Extensions {
public static string GetIdString(this byte[] buffer) {
const string id_chars = "abcdefghijklmnopqrstuvwxyz0123456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ";
2023-02-07 15:01:56 +00:00
StringBuilder sb = new();
2022-08-30 15:00:58 +00:00
foreach(byte b in buffer)
sb.Append(id_chars[b % id_chars.Length]);
return sb.ToString();
}
}
}