From ad7f4f17880105a636d954de4a311b6c863527c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20=C5=9Apiewak?= Date: Tue, 20 Aug 2024 15:01:08 +0200 Subject: [PATCH] Simplify code. --- ArcFormats/DxLib/DxKey.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ArcFormats/DxLib/DxKey.cs b/ArcFormats/DxLib/DxKey.cs index 5e5ba6b9..44c57901 100644 --- a/ArcFormats/DxLib/DxKey.cs +++ b/ArcFormats/DxLib/DxKey.cs @@ -182,12 +182,10 @@ namespace GameRes.Formats.DxLib keyword += "DXARC"; } //first split string to bytes. Use original encoding as basis. Otherwise we would fail to decrypt that. - Encoding defEncoding = Encoding.UTF8; Encoding tgtEncoding = Encoding.GetEncoding(codepage); - byte[] defBytes = defEncoding.GetBytes(keyword); - byte[] tgtBytes = Encoding.Convert(defEncoding, tgtEncoding, defBytes); - byte[] oddBuffer = new byte[tgtBytes.Length]; int oddCounter = 0; - byte[] evenBuffer = new byte[tgtBytes.Length]; int evenCounter = 0; + byte[] tgtBytes = tgtEncoding.GetBytes(keyword); + byte[] oddBuffer = new byte[(tgtBytes.Length/2)+(tgtBytes.Length%2)]; int oddCounter = 0; + byte[] evenBuffer = new byte[(tgtBytes.Length/2)]; int evenCounter = 0; for (int i=0; i