/// <summary> /// 从nbt数据中获取salt /// </summary> /// <param name="data"></param> /// <param name="is112">是否是1.12版本, 如果是, 那么只需要处理一位数字</param> /// <returns></returns> public static string GetSaltFromNBTByteArray(byte[] data, bool is112) { MemoryStream ms = new MemoryStream(removeLength(data, is112)); TagCompound tag = NBTFile.FromStream(ms); byte[] saltarr = tag.GetByteArray("salt"); string salt = System.Text.Encoding.UTF8.GetString(saltarr); if (saltarr.Length > 100) { salt = ASACUtil.RSADecodeSalt(saltarr); } return(salt); }
/// <summary> /// 判断是否需要rsa加密 /// 只有1.0.6及以下需要 /// </summary> /// <param name="md5Data"></param> /// <returns></returns> public static bool IsNeedRSA(byte[] md5Data, bool is112) { bool isRsa = false; MemoryStream ms = new MemoryStream(removeLength(md5Data, is112)); TagCompound tag = NBTFile.FromStream(ms); TagList taglist = (TagList)tag["md5s"]; foreach (TagByteArray br in taglist) { byte[] bytes = br.Value; if (bytes.Length > 100) { isRsa = true; break; } } return(isRsa); }
private AnvilChunk LoadChunk(ChunkCoord coord) { RegionFile f = FetchRegion(coord.RegionCoord); TagCompound chunkTag = null; using (Stream stream = f.ReadChunk(new ChunkCoord(coord.X & 31, coord.Z & 31))) { if (stream != null) { chunkTag = NBTFile.FromStream(stream, false); } } if (chunkTag == null) { return(null); } return(AnvilChunkImproved.Load(this, chunkTag)); }
/// <summary> /// 从nbt数据中心获取md5字符串列表 /// </summary> /// <param name="data"></param> /// <returns></returns> public static List <string> GetMd5ListFromNBTByteArray(byte[] data, bool is112) { List <string> md5s = new List <string>(); MemoryStream ms = new MemoryStream(removeLength(data, is112)); TagCompound tag = NBTFile.FromStream(ms); TagList taglist = (TagList)tag["md5s"]; foreach (TagByteArray br in taglist) { byte[] bytes = br.Value; if (bytes.Length > 100) { string md5 = ASACUtil.RSADecodeMD5(bytes); md5s.Add(md5); } else { md5s.Add(Encoding.UTF8.GetString(bytes)); } } return(md5s); }