public async Task WriteRead8ByteNumber(ulong value) { using MemoryStream ms = new MemoryStream(); using BinaryDataStream stream = new BinaryDataStream(ms); await stream.Write8BitNumber(value); await stream.FlushAsync(); stream.Position = 0; ulong readedValue = await stream.Read8BitNumber(); Assert.AreEqual(value, readedValue); }
public async Task WriteToStream(Stream stream) { using (BinaryDataStream dataStream = new BinaryDataStream(stream, false)) { await dataStream.WriteConstantString(HeaderPrefix, Encoding.ASCII); await dataStream.Write2BitNumber(this.Version); await dataStream.Write4BitNumber(0); await dataStream.Write4BitNumber((uint)this.KeyType); await dataStream.Write8BitNumber(this.EncryptedDataSize); await dataStream.WriteConstantString(this.CertificateThumbprint, Encoding.ASCII); await dataStream.WriteAsync(this.EncryptedKey, 0, this.EncryptedKey.Length); await dataStream.WriteAsync(this.InitializeVector, 0, this.InitializeVector.Length); await dataStream.FlushAsync(); } }