Skip to content
nsZip is a tool to compress/decompress Nintendo Switch games using the here specified NSZ file format
Branch: master
Clone or download
Latest commit 2b78910 Apr 29, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Crypto Way faster verification speed by using System.Security.Cryptography.S… Mar 3, 2019
LibHac Way faster verification speed by using System.Security.Cryptography.S… Mar 3, 2019
LibHacControl Fixed XCI compression by properly closing xciMeta.dat and phrasing th… Apr 29, 2019
LibHacExtensions Implemented CLI control Apr 9, 2019
Properties Implemented CLI control Apr 9, 2019
.gitattributes Initial commit Jan 23, 2019
.gitignore Initial commit Jan 23, 2019
App.config Refactored the code to fit my coding style guidelines and fixed a few… Feb 28, 2019
App.xaml Separated the task from UI for CLI usage and closing the files on exc… Apr 1, 2019
App.xaml.cs Implemented CLI control Apr 9, 2019
CommandLineArguments.cs Implemented CLI control Apr 9, 2019
CompressFolder.cs Fixed an integer overflow error which caused the program to crash whe… Mar 18, 2019
DecompressFs.cs Extract and decompress NSP, CXI, NSPZ and XCIZ files in one step with… Mar 1, 2019
EncryptNCA.cs Separated the task from UI for CLI usage and closing the files on exc… Apr 1, 2019
LICENSE Created UI for the advanced settings and about tab, started with thei… Feb 26, 2019
MainWindow.xaml nsZip v2.0.0 preview 2 Apr 29, 2019
MainWindow.xaml.cs Implemented CLI control Apr 9, 2019
Output.cs Removed unused includes and improved the source codes readability by … Feb 22, 2019
README.md Improved the NSZ file format specifications Jan 27, 2019
TaskLogic.cs Implemented CLI control Apr 9, 2019
Utils.cs Code cleanup to always use a { } block even for a single line to impr… Jan 24, 2019
nsZip.csproj Implemented CLI control Apr 9, 2019
nsZip.ico Version 1.0.0-rc.14 Jan 31, 2019
nsZip.psd
nsZip.sln Way faster encryption speed by using the same Aes128CtrTransform as u… Mar 2, 2019
packages.config Removed unused includes and improved the source codes readability by … Feb 22, 2019

README.md

nsZip

Work in progress file format for compressed Nintendo Switch games and a tool to compress/decompress them.

NSZ file format:

Header:

Offset Size Description
0x00 0x05 XOR-Encrypted magic ("nsZip")
0x05 0x05 Random key to decrypt the magic
0x0A 0x01 Version (for now 0x00)
0x0B 0x01 nsZip Type

Type 0:

Offset Size Description
0x0C 0x01 Compression algorithm
0x0D File size - 0x1D Full compressed file
File size - 0x10 0x10 (first half) SHA256 of everything above

Type 1:

Offset Size Description
0x0C 0x05 bs = Decompressed Block Size
0x11 0x04 Amount of Blocks
0x15 + x * y 0x01 Compression algorithm
0x16 + x * y y - 1 cbs = Compressed Block Size
0x15 + (x+1) * y sum(cbs) Concatenated compressed blocks
File size - 0x10 0x10 (first half) SHA256 header XOR SHA256 compressed

y = ceil(log2(bs)/8) + 1

Note: The compressed block isn't allowed to be larger than the decompressed data - please use compression algorithm 0x00 (None) in that case or cbs might overflow!

Type 2:

Offset Size Description
0x0C 0x04 Amount of Blocks
0x10 0x01 s = Size of size parameters
0x11 + x * y 0x01 Compression algorithm
0x12 + x * y s bs = Decompressed Block Size
0x12 + x * y + s s cbs = Compressed Block Size
0x12 + (x+1) * y sum(cbs) Concatenated compressed blocks
File size - 0x10 0x10 (first half) SHA256 header XOR SHA256 compressed

y = 2 * s + 1

Compression algorithms:

Value Algorithm Recommended Parameters
0x00 None None - Just use memcpy
0x01 Zstandard CompressionLevel = 19
0x02 lzma Dic=1536, WordS=273, cLevel=9
You can’t perform that action at this time.