Skip to content

Commit cc04517

Browse files
committed
Use BE methods on Pack.
1 parent 7c05bd1 commit cc04517

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/Renci.SshNet/Common/SshData.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ protected bool ReadBoolean()
209209
/// <returns>uint16 read</returns>
210210
protected ushort ReadUInt16()
211211
{
212-
var data = ReadBytes(2);
213-
return (ushort)(data[0] << 8 | data[1]);
212+
return Pack.BigEndianToUInt16(ReadBytes(2));
214213
}
215214

216215
/// <summary>
@@ -219,8 +218,7 @@ protected ushort ReadUInt16()
219218
/// <returns>uint32 read</returns>
220219
protected uint ReadUInt32()
221220
{
222-
var data = ReadBytes(4);
223-
return (uint)(data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]);
221+
return Pack.BigEndianToUInt32(ReadBytes(4));
224222
}
225223

226224
/// <summary>
@@ -229,8 +227,7 @@ protected uint ReadUInt32()
229227
/// <returns>uint64 read</returns>
230228
protected ulong ReadUInt64()
231229
{
232-
var data = ReadBytes(8);
233-
return ((ulong)data[0] << 56 | (ulong)data[1] << 48 | (ulong)data[2] << 40 | (ulong)data[3] << 32 | (ulong)data[4] << 24 | (ulong)data[5] << 16 | (ulong)data[6] << 8 | data[7]);
230+
return Pack.BigEndianToUInt64(ReadBytes(8));
234231
}
235232

236233
/// <summary>

0 commit comments

Comments
 (0)