modernize minecraft utils

This commit is contained in:
Pilzinsel64
2025-07-10 06:18:03 +02:00
parent b4d77667bc
commit bdeb098dc4

View File

@@ -7,11 +7,9 @@ public static class Utils
{ {
public static string GetUUID(string value) public static string GetUUID(string value)
{ {
using var md5 = MD5.Create();
//extracted from the java code: //extracted from the java code:
//new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name)); //new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name));
byte[] data = md5.ComputeHash(Encoding.ASCII.GetBytes(value)); var data = MD5.HashData(Encoding.ASCII.GetBytes(value));
//set the version to 3 -> Name based md5 hash //set the version to 3 -> Name based md5 hash
data[6] = Convert.ToByte(data[6] & 0x0f | 0x30); data[6] = Convert.ToByte(data[6] & 0x0f | 0x30);
//IETF variant //IETF variant