本文整理汇总了C#中Entry.CalculateHashes方法的典型用法代码示例。如果您正苦于以下问题:C# Entry.CalculateHashes方法的具体用法?C# Entry.CalculateHashes怎么用?C# Entry.CalculateHashes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry.CalculateHashes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
public void Deserialize(Stream input)
{
var basePosition = input.Position;
// read as two unsigned longs so we don't have to actually
// decode the strings
var version1 = input.ReadValueU64(false);
var version2 = input.ReadValueU64(false);
if (version1 == 0x4552462056322E31) // ERF V2.1
{
input.Seek(basePosition + 8, SeekOrigin.Begin);
throw new NotSupportedException();
}
else if (version1 == 0x4500520046002000 &&
version2 == 0x560032002E003000) // ERF V2.0
{
input.Seek(basePosition + 16, SeekOrigin.Begin);
this.Version = 1;
var fileCount = input.ReadValueU32();
var unknown14 = input.ReadValueU32();
var unknown18 = input.ReadValueU32();
var unknown1C = input.ReadValueU32();
this.Flags = 0;
this.Encryption = EncryptionScheme.None;
this.Compression = CompressionScheme.None;
this.ContentId = 0;
this.PasswordDigest = null;
this.Entries.Clear();
for (uint i = 0; i < fileCount; i++)
{
var entry = new Entry();
entry.Name = input.ReadString(64, true, Encoding.Unicode);
entry.CalculateHashes();
entry.Offset = input.ReadValueU32();
entry.UncompressedSize = input.ReadValueU32();
entry.CompressedSize = entry.UncompressedSize;
this.Entries.Add(entry);
}
}
else if (version1 == 0x4500520046002000 &&
version2 == 0x560032002E003200) // ERF V2.2
{
input.Seek(basePosition + 16, SeekOrigin.Begin);
this.Version = 2;
var fileCount = input.ReadValueU32();
var year = input.ReadValueU32();
var day = input.ReadValueU32();
var unknown1C = input.ReadValueU32(); // always 0xFFFFFFFF?
var flags = input.ReadValueU32();
var contentId = input.ReadValueU32();
var passwordDigest = new byte[16];
input.Read(passwordDigest, 0, passwordDigest.Length);
if (unknown1C != 0xFFFFFFFF)
{
throw new InvalidOperationException();
}
this.Flags = (flags & 0x1FFFFF0F) >> 0;
this.Encryption = (EncryptionScheme)((flags & 0x000000F0) >> 4);
this.Compression = (CompressionScheme)((flags & 0xE0000000) >> 29);
if (this.Flags != 0 && this.Flags != 1)
{
throw new FormatException("unknown flags value");
}
this.ContentId = contentId;
this.PasswordDigest = passwordDigest;
this.Entries.Clear();
for (uint i = 0; i < fileCount; i++)
{
var entry = new Entry();
entry.Name = input.ReadString(64, true, Encoding.Unicode);
entry.CalculateHashes();
entry.Offset = input.ReadValueU32();
entry.CompressedSize = input.ReadValueU32();
entry.UncompressedSize = input.ReadValueU32();
this.Entries.Add(entry);
}
}
else if (version1 == 0x4500520046002000 &&
version2 == 0x560033002E003000) // ERF V3.0
{
input.Seek(basePosition + 16, SeekOrigin.Begin);
this.Version = 3;
var stringTableSize = input.ReadValueU32();
var fileCount = input.ReadValueU32();
var flags = input.ReadValueU32();
//.........这里部分代码省略.........