mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Removed dependency on Crc32.NET
This commit is contained in:
parent
593463f46b
commit
53ee143a1d
|
|
@ -27,7 +27,7 @@ Then it will attempt to sign-in as a user for which you must enter the **phone_n
|
||||||
|
|
||||||
If the verification succeeds but the phone number is unknown to Telegram, the user might be prompted to sign-up (accepting the Terms of Service) and enter their **first_name** and **last_name**.
|
If the verification succeeds but the phone number is unknown to Telegram, the user might be prompted to sign-up (accepting the Terms of Service) and enter their **first_name** and **last_name**.
|
||||||
|
|
||||||
And that's it, you now have access to the full range of Telegram services, mainly through calls to `await client.Some_TL_Method(...)`
|
And that's it, you now have access to the [full range of Telegram services](https://core.telegram.org/methods), mainly through calls to `await client.Some_TL_Method(...)`
|
||||||
|
|
||||||
# Saved session
|
# Saved session
|
||||||
If you run this program again, you will notice that the previous prompts are gone and you are automatically logged-on and ready to go.
|
If you run this program again, you will notice that the previous prompts are gone and you are automatically logged-on and ready to go.
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ namespace WTelegram
|
||||||
var buffer = memStream.GetBuffer();
|
var buffer = memStream.GetBuffer();
|
||||||
int frameLength = (int)memStream.Length;
|
int frameLength = (int)memStream.Length;
|
||||||
BinaryPrimitives.WriteInt32LittleEndian(buffer, frameLength + 4); // patch frame_len with correct value
|
BinaryPrimitives.WriteInt32LittleEndian(buffer, frameLength + 4); // patch frame_len with correct value
|
||||||
uint crc = Force.Crc32.Crc32Algorithm.Compute(buffer, 0, frameLength);
|
uint crc = Helpers.UpdateCrc32(0, buffer, 0, frameLength);
|
||||||
writer.Write(crc); // int32 frame_crc
|
writer.Write(crc); // int32 frame_crc
|
||||||
//TODO: support Transport obfuscation?
|
//TODO: support Transport obfuscation?
|
||||||
|
|
||||||
|
|
@ -277,8 +277,8 @@ namespace WTelegram
|
||||||
var payload = new byte[length];
|
var payload = new byte[length];
|
||||||
if (await FullReadAsync(_networkStream, payload, length, ct) != length)
|
if (await FullReadAsync(_networkStream, payload, length, ct) != length)
|
||||||
throw new ApplicationException("Could not read frame data : Connection shut down");
|
throw new ApplicationException("Could not read frame data : Connection shut down");
|
||||||
uint crc32 = Force.Crc32.Crc32Algorithm.Compute(frame, 0, 8);
|
uint crc32 = Helpers.UpdateCrc32(0, frame, 0, 8);
|
||||||
crc32 = Force.Crc32.Crc32Algorithm.Append(crc32, payload);
|
crc32 = Helpers.UpdateCrc32(crc32, payload, 0, payload.Length);
|
||||||
if (await FullReadAsync(_networkStream, frame, 4, ct) != 4)
|
if (await FullReadAsync(_networkStream, frame, 4, ct) != 4)
|
||||||
throw new ApplicationException("Could not read frame CRC : Connection shut down");
|
throw new ApplicationException("Could not read frame CRC : Connection shut down");
|
||||||
if (crc32 != BinaryPrimitives.ReadUInt32LittleEndian(frame))
|
if (crc32 != BinaryPrimitives.ReadUInt32LittleEndian(frame))
|
||||||
|
|
|
||||||
|
|
@ -189,5 +189,11 @@ namespace WTelegram
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// see also https://github.com/dotnet/runtime/issues/2036 and https://github.com/dotnet/runtime/pull/53623
|
||||||
|
internal static readonly Func<uint, byte[], int, int, uint> UpdateCrc32 = (Func<uint, byte[], int, int, uint>)
|
||||||
|
typeof(System.IO.Compression.ZipArchive).Assembly.GetType("System.IO.Compression.Crc32Helper")
|
||||||
|
.GetMethod("UpdateCrc32", new[] { typeof(uint), typeof(byte[]), typeof(int), typeof(int) })
|
||||||
|
.CreateDelegate(typeof(Func<uint, byte[], int, int, uint>));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Crc32.NET" Version="1.2.0" />
|
|
||||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue