Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var stream = new System.IO.MemoryStream();
- var writer = new System.IO.BinaryWriter(stream);
- int fileType = 9 | 1 << 25;
- int dcId = 2;
- long id_ = long.Parse(id);
- long access_hash_ = long.Parse(access_hash);
- writer.Write(fileType);
- writer.Write(dcId);
- var b = Encoding.UTF8.GetBytes(file_reference_base64);
- if (b.Length <= 253)
- {
- writer.Write((byte)b.Length);
- }
- else
- {
- writer.Write((byte)254);
- writer.Write((byte)b.Length);
- writer.Write((byte)(b.Length >> 8));
- writer.Write((byte)(b.Length >> 16));
- }
- writer.Write(b);
- int j = b.Length <= 253 ? 1 : 4;
- while ((b.Length + j) % 4 != 0)
- {
- writer.Write((byte)0);
- j++;
- }
- writer.Write(id_);
- writer.Write(access_hash_);
- writer.Write((byte)30);
- writer.Write((byte)4);
- writer.Flush();
- stream.Seek(0, System.IO.SeekOrigin.Begin);
- var bytes = stream.ToArray();
- var result = new List<byte>();
- for (int n = bytes.Length, i = 0; i < n; i++)
- {
- result.Add(bytes[i]);
- if (bytes[i] == 0)
- {
- byte cnt = 1;
- while (cnt < 250 && i + cnt < n && bytes[i + cnt] == bytes[i])
- {
- cnt++;
- }
- result.Add(cnt);
- i += cnt - 1;
- }
- }
Add Comment
Please, Sign In to add comment