/// <summary> /// Repacks and encrypts DS3's regulation BND4 to the specified path. /// </summary> public static void EncryptDS3Regulation(string path, BND4 bnd) { byte[] bytes = bnd.Write(); bytes = EncryptByteArray(ds3RegulationKey, bytes); Directory.CreateDirectory(Path.GetDirectoryName(path)); File.WriteAllBytes(path, bytes); }
private void Read(BinaryReaderEx br) { br = SFUtil.GetDecompressedBR(br, out DCX.Type compression); Compression = compression; Files = BND4.ReadHeader(this, br); DataBR = br; }
/// <summary> /// Decrypts and unpacks DS2's regulation BND4 from the specified path. /// </summary> public static BND4 DecryptDS2Regulation(string path) { byte[] bytes = File.ReadAllBytes(path); byte[] iv = new byte[16]; iv[0] = 0x80; Array.Copy(bytes, 0, iv, 1, 11); iv[15] = 1; byte[] input = new byte[bytes.Length - 32]; Array.Copy(bytes, 32, input, 0, bytes.Length - 32); using (var ms = new MemoryStream(input)) { byte[] decrypted = CryptographyUtility.DecryptAesCtr(ms, ds2RegulationKey, iv); return(BND4.Read(decrypted)); } }
/// <summary> /// Decrypts and unpacks DS3's regulation BND4 from the specified path. /// </summary> public static BND4 DecryptDS3Regulation(string path) { byte[] bytes = File.ReadAllBytes(path); bytes = DecryptByteArray(ds3RegulationKey, bytes); return(BND4.Read(bytes)); }