diff --git a/.github/workflows/build_program.yml b/.github/workflows/build_program.yml
index 2fe0023..a6af6a7 100644
--- a/.github/workflows/build_program.yml
+++ b/.github/workflows/build_program.yml
@@ -12,7 +12,7 @@ jobs:
matrix:
project: [NDecrypt]
runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64]
- framework: [net8.0] #[net20, net35, net40, net452, net472, net48, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0]
+ framework: [net9.0] #[net20, net35, net40, net452, net472, net48, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0, net9.0]
conf: [Debug] #[Release, Debug]
steps:
@@ -23,13 +23,13 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
- dotnet-version: 8.0.x
+ dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
- run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8')) && '-p:PublishSingleFile=true' || ''}}
+ run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8') || startsWith(matrix.framework, 'net9')) && '-p:PublishSingleFile=true' || ''}}
- name: Archive build
run: |
diff --git a/.github/workflows/check_pr.yml b/.github/workflows/check_pr.yml
index bba92af..fad7fe2 100644
--- a/.github/workflows/check_pr.yml
+++ b/.github/workflows/check_pr.yml
@@ -11,7 +11,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
- dotnet-version: 8.0.x
+ dotnet-version: 9.0.x
- name: Build
run: dotnet build
\ No newline at end of file
diff --git a/.vscode/launch.json b/.vscode/launch.json
index b60752a..edd6a47 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/NDecrypt/bin/Debug/net8.0/NDecrypt.dll",
+ "program": "${workspaceFolder}/NDecrypt/bin/Debug/net9.0/NDecrypt.dll",
"args": [],
"cwd": "${workspaceFolder}/NDecrypt",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
diff --git a/NDecrypt.Core/CommonOperations.cs b/NDecrypt.Core/CommonOperations.cs
index 5d7f9d3..2ed107d 100644
--- a/NDecrypt.Core/CommonOperations.cs
+++ b/NDecrypt.Core/CommonOperations.cs
@@ -1,6 +1,5 @@
using System;
using System.IO;
-using System.Linq;
using System.Numerics;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
@@ -140,7 +139,10 @@ namespace NDecrypt.Core
/// 16-byte array representing the BigInteger
private static byte[] TakeSixteen(BigInteger input)
{
- var arr = input.ToByteArray().Take(16).Reverse().ToArray();
+ var inputArr = input.ToByteArray();
+ var arr = new byte[16];
+ Array.Copy(inputArr, arr, Math.Min(inputArr.Length, 16));
+ Array.Reverse(arr);
if (arr.Length < 16)
{
@@ -168,9 +170,12 @@ namespace NDecrypt.Core
public static byte[] AddToByteArray(byte[] input, int add)
{
int len = input.Length;
- var bigint = new BigInteger(input.Reverse().ToArray());
+ Array.Reverse(input);
+ var bigint = new BigInteger(input);
+
bigint += add;
- var arr = bigint.ToByteArray().Reverse().ToArray();
+ var arr = bigint.ToByteArray();
+ Array.Reverse(arr);
if (arr.Length < len)
{
diff --git a/NDecrypt.Core/DSTool.cs b/NDecrypt.Core/DSTool.cs
index 8940d22..b8d4e1c 100644
--- a/NDecrypt.Core/DSTool.cs
+++ b/NDecrypt.Core/DSTool.cs
@@ -1,6 +1,5 @@
using System;
using System.IO;
-using System.Linq;
using SabreTools.IO.Extensions;
using SabreTools.Models.Nitro;
using NitroDeserializer = SabreTools.Serialization.Deserializers.Nitro;
@@ -667,10 +666,9 @@ namespace NDecrypt.Core
Encrypt(ref _arg2[2], ref _arg2[1]);
Encrypt(ref _arg2[1], ref _arg2[0]);
- byte[] allBytes = BitConverter.GetBytes(_arg2[0])
- .Concat(BitConverter.GetBytes(_arg2[1]))
- .Concat(BitConverter.GetBytes(_arg2[2]))
- .ToArray();
+ byte[] allBytes =[.. BitConverter.GetBytes(_arg2[0]),
+ .. BitConverter.GetBytes(_arg2[1]),
+ .. BitConverter.GetBytes(_arg2[2])];
UpdateHashtable(allBytes);
}
diff --git a/NDecrypt.Core/DecryptArgs.cs b/NDecrypt.Core/DecryptArgs.cs
index af9626f..7f33a95 100644
--- a/NDecrypt.Core/DecryptArgs.cs
+++ b/NDecrypt.Core/DecryptArgs.cs
@@ -1,6 +1,5 @@
using System;
using System.IO;
-using System.Linq;
using System.Numerics;
using SabreTools.IO.Extensions;
using SabreTools.IO.Readers;
@@ -117,8 +116,9 @@ namespace NDecrypt.Core
break;
var kvp = reader.KeyValuePair!.Value;
- byte[] value = StringToByteArray(kvp.Value).Reverse().ToArray();
- byte[] valueWithSign = value.Concat(signByte).ToArray();
+ byte[] value = StringToByteArray(kvp.Value);
+ Array.Reverse(value);
+ byte[] valueWithSign = [.. value, .. signByte];
switch (kvp.Key)
{
diff --git a/NDecrypt.Core/NDecrypt.Core.csproj b/NDecrypt.Core/NDecrypt.Core.csproj
index e43337a..b58a3ea 100644
--- a/NDecrypt.Core/NDecrypt.Core.csproj
+++ b/NDecrypt.Core/NDecrypt.Core.csproj
@@ -1,46 +1,56 @@
-
-
- net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0
- false
- false
- latest
- enable
- true
- true
- 0.2.5
+
+
+ net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0
+ false
+ false
+ latest
+ enable
+ true
+ true
+ 0.2.5
-
- Matt Nadareski
- Common code for all NDecrypt processors
- Copyright (c) Matt Nadareski 2019-2024
- MIT
- https://github.com/SabreTools/
- https://github.com/SabreTools/NDecrypt
- git
-
+
+ Matt Nadareski
+ Common code for all NDecrypt processors
+ Copyright (c) Matt Nadareski 2019-2024
+ MIT
+ https://github.com/SabreTools/
+ https://github.com/SabreTools/NDecrypt
+ git
+
-
-
- win-x86;win-x64
-
-
- win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64
-
-
- win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64
-
-
- net6.0;net7.0;net8.0
-
+
+
+ win-x86;win-x64
+
+
+ win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64
+
+
+ win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64
+
+
+ net6.0;net7.0;net8.0;net9.0
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/NDecrypt.Core/PartitionKeys.cs b/NDecrypt.Core/PartitionKeys.cs
index 523862d..186703d 100644
--- a/NDecrypt.Core/PartitionKeys.cs
+++ b/NDecrypt.Core/PartitionKeys.cs
@@ -1,5 +1,4 @@
using System;
-using System.Linq;
using System.Numerics;
using Org.BouncyCastle.Crypto;
using SabreTools.Models.N3DS;
@@ -58,9 +57,16 @@ namespace NDecrypt.Core
// Backup headers can't have a KeyY value set
if (signature != null)
- KeyY = new BigInteger(signature.Take(16).Reverse().ToArray());
+ {
+ byte[] signature16 = new byte[16];
+ Array.Copy(signature, signature16, 16);
+ Array.Reverse(signature16);
+ KeyY = new BigInteger(signature16);
+ }
else
+ {
KeyY = new BigInteger(0);
+ }
// Set the standard normal key values
NormalKey = 0x00;
diff --git a/NDecrypt/HashingHelper.cs b/NDecrypt/HashingHelper.cs
index dd8c149..02b4054 100644
--- a/NDecrypt/HashingHelper.cs
+++ b/NDecrypt/HashingHelper.cs
@@ -1,5 +1,4 @@
using System.IO;
-using System.Linq;
using SabreTools.Hashing;
namespace NDecrypt
@@ -25,10 +24,10 @@ namespace NDecrypt
// Get the results
return $"Size: {size}\n"
- + $"CRC32: {hashDict.First(h => h.Key == HashType.CRC32).Value ?? string.Empty}\n"
- + $"MD5: {hashDict.First(h => h.Key == HashType.MD5).Value ?? string.Empty}\n"
- + $"SHA1: {hashDict.First(h => h.Key == HashType.SHA1).Value ?? string.Empty}\n"
- + $"SHA256: {hashDict.First(h => h.Key == HashType.SHA256).Value ?? string.Empty}\n";
+ + $"CRC-32: {(hashDict.ContainsKey(HashType.CRC32) ? hashDict[HashType.CRC32] : string.Empty)}\n"
+ + $"MD5: {(hashDict.ContainsKey(HashType.MD5) ? hashDict[HashType.MD5] : string.Empty)}\n"
+ + $"SHA-1: {(hashDict.ContainsKey(HashType.SHA1) ? hashDict[HashType.SHA1] : string.Empty)}\n"
+ + $"CSHA-256: {(hashDict.ContainsKey(HashType.SHA256) ? hashDict[HashType.SHA256] : string.Empty)}\n";
}
}
}
diff --git a/NDecrypt/NDecrypt.csproj b/NDecrypt/NDecrypt.csproj
index 6699d1f..9694bdf 100644
--- a/NDecrypt/NDecrypt.csproj
+++ b/NDecrypt/NDecrypt.csproj
@@ -1,44 +1,47 @@
-
-
- net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0
- Exe
- false
- false
- latest
- enable
- true
- true
- 0.2.5
+
+
+ net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0
+ Exe
+ false
+ false
+ latest
+ enable
+ true
+ true
+ 0.2.5
-
- NDecrypt
- Matt Nadareski
- DS/3DS Encryption Tool
- Copyright (c) Matt Nadareski 2018-2024
- MIT
- https://github.com/SabreTools/
- https://github.com/SabreTools/NDecrypt
- git
-
+
+ NDecrypt
+ Matt Nadareski
+ DS/3DS Encryption Tool
+ Copyright (c) Matt Nadareski 2018-2024
+ MIT
+ https://github.com/SabreTools/
+ https://github.com/SabreTools/NDecrypt
+ git
+
-
-
- win-x86;win-x64
-
-
- win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64
-
-
- win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64
-
-
- net6.0;net7.0;net8.0
-
+
+
+ win-x86;win-x64
+
+
+ win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64
+
+
+ win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64
+
+
+ net6.0;net7.0;net8.0;net9.0
+
-
-
-
+
+
+
-
+
\ No newline at end of file
diff --git a/publish-nix.sh b/publish-nix.sh
index 457eae4..a179726 100644
--- a/publish-nix.sh
+++ b/publish-nix.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# This batch file assumes the following:
-# - .NET 8.0 (or newer) SDK is installed and in PATH
+# - .NET 9.0 (or newer) SDK is installed and in PATH
# - zip is installed and in PATH
# - Git is installed and in PATH
#
@@ -44,18 +44,18 @@ echo " No archive (-a) $NO_ARCHIVE"
echo " "
# Create the build matrix arrays
-FRAMEWORKS=("net8.0")
+FRAMEWORKS=("net9.0")
RUNTIMES=("win-x86" "win-x64" "win-arm64" "linux-x64" "linux-arm64" "osx-x64" "osx-arm64")
# Use expanded lists, if requested
if [ $USE_ALL = true ]; then
- FRAMEWORKS=("net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0")
+ FRAMEWORKS=("net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0")
fi
# Create the filter arrays
-SINGLE_FILE_CAPABLE=("net5.0" "net6.0" "net7.0" "net8.0")
-VALID_APPLE_FRAMEWORKS=("net6.0" "net7.0" "net8.0")
-VALID_CROSS_PLATFORM_FRAMEWORKS=("netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0")
+SINGLE_FILE_CAPABLE=("net5.0" "net6.0" "net7.0" "net8.0" "net9.0")
+VALID_APPLE_FRAMEWORKS=("net6.0" "net7.0" "net8.0" "net9.0")
+VALID_CROSS_PLATFORM_FRAMEWORKS=("netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0")
VALID_CROSS_PLATFORM_RUNTIMES=("win-arm64" "linux-x64" "linux-arm64" "osx-x64" "osx-arm64")
# Only build if requested
diff --git a/publish-win.ps1 b/publish-win.ps1
index 51feee1..c23db4c 100644
--- a/publish-win.ps1
+++ b/publish-win.ps1
@@ -1,5 +1,5 @@
# This batch file assumes the following:
-# - .NET 8.0 (or newer) SDK is installed and in PATH
+# - .NET 9.0 (or newer) SDK is installed and in PATH
# - 7-zip commandline (7z.exe) is installed and in PATH
# - Git for Windows is installed and in PATH
#
@@ -35,18 +35,18 @@ Write-Host " No archive (-NoArchive) $NO_ARCHIVE"
Write-Host " "
# Create the build matrix arrays
-$FRAMEWORKS = @('net8.0')
+$FRAMEWORKS = @('net9.0')
$RUNTIMES = @('win-x86', 'win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64')
# Use expanded lists, if requested
if ($USE_ALL.IsPresent) {
- $FRAMEWORKS = @('net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0')
+ $FRAMEWORKS = @('net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0')
}
# Create the filter arrays
-$SINGLE_FILE_CAPABLE = @('net5.0', 'net6.0', 'net7.0', 'net8.0')
-$VALID_APPLE_FRAMEWORKS = @('net6.0', 'net7.0', 'net8.0')
-$VALID_CROSS_PLATFORM_FRAMEWORKS = @('netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0')
+$SINGLE_FILE_CAPABLE = @('net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0')
+$VALID_APPLE_FRAMEWORKS = @('net6.0', 'net7.0', 'net8.0', 'net9.0')
+$VALID_CROSS_PLATFORM_FRAMEWORKS = @('netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0')
$VALID_CROSS_PLATFORM_RUNTIMES = @('win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64')
# Only build if requested