Skip to content

Commit 25c810a

Browse files
committed
replace windows with unix line endings
and remove BOM from config file
1 parent 51c3eca commit 25c810a

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

SPHDecode/Implementations/Cryptography.cs

+3-7
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,11 @@ private static byte[] AESHelper (byte[] data, bool decrypt = false)
9090
encryptor.IV = IV;
9191

9292
MemoryStream ms = new MemoryStream();
93-
CryptoStream cs;
93+
CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write);
94+
9495
if (decrypt)
95-
{
9696
cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write);
97-
}
98-
else {
99-
cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write);
100-
}
101-
97+
10298
cs.Write(data, 0, data.Length);
10399
cs.Close();
104100

SPHDecode/Model/MainWindowModel.cs

+6
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ private void OndstFileDialogExecute()
7272
private void OnencryptExecute()
7373
{
7474
string orig = File.ReadAllText(srcFile);
75+
// remove BOM from utf-8 file
76+
orig = orig.Replace("\ufeff", "");
77+
78+
// replace windows with unix line endings
79+
orig = orig.Replace("\r\n", "\n").Replace("\r", "\n");
80+
7581
byte[] encode = Cryptography.Encrypt(orig);
7682
if (Object.Equals(encode, null).Equals(false))
7783
{

0 commit comments

Comments
 (0)