//Second Version /// <summary> /// Объявление структуры /// </summary> /// <param name="Name">Имя</param> /// <param name="Quest">Квест</param> /// <param name="ReadOnly">Только для чтения</param> public File(string Name, string Quest, byte ReadOnly) { Version = FileVersion.Two; this.Name = Name; this.Quest = Quest; this.ReadOnly = ByteToBool(ReadOnly); this.DigitalSign = null; this.Author = Environment.UserName; Checksym = Crc32.CRC32(Name + Quest); }
//First Version /// <summary> /// Объявление структуры /// </summary> /// <param name="Name">Имя</param> /// <param name="Quest">Квест</param> public File(string Name, string Quest) { Version = FileVersion.One; this.Name = Name; this.Quest = Quest; this.ReadOnly = false; this.DigitalSign = null; this.Author = Environment.UserName; Checksym = Crc32.CRC32(Name + Quest); }
/// <summary> /// Объявление структуры /// </summary> /// <param name="Name">Имя</param> /// <param name="Quest">Квест</param> /// <param name="version">Версия</param> /// <param name="checksym">Контрольная сумма</param> public File(string Name, string Quest, FormatVersion version, byte[] checksym) { Version = GetVersion(version); this.Name = Name; this.Quest = Quest; this.ReadOnly = false; this.DigitalSign = null; this.Author = Environment.UserName; Checksym = checksym; if (!Crc32.IsValidCRC(Crc32.CRC32(Name + Quest), checksym)) { throw new Exception("CRC32 не верный"); } }
/// <summary> /// Объявление структуры /// </summary> /// <param name="Name">Имя</param> /// <param name="Quest">Квест</param> /// <param name="version">Версия</param> /// <param name="checksym">Контрольная сумма</param> /// <param name="ReadOnly">Только для чтения</param> /// <param name="DigitalSign">Цифровая подпись</param> public File(string Name, string Quest, FormatVersion version, byte[] checksym, byte ReadOnly, byte[] DigitalSign, string Author) { Version = GetVersion(version); this.Name = Name; this.Quest = Quest; this.DigitalSign = DigitalSign; Checksym = checksym; this.ReadOnly = ByteToBool(ReadOnly); this.Author = Author; if (!QuestLibrary.QuestFiles.Sign.Sign.CorrectSign(DigitalSign)) { throw new Exception("Цифровая подпись неверная"); } if (!Crc32.IsValidCRC(Crc32.CRC32(Name + Quest), checksym)) { throw new Exception("CRC32 не верный"); } }