ZSTD壓縮算法,一個壓縮/解壓縮腳本(帶有可選的GUI),允許用戶可以無光自發地壓縮Nintendo Switch轉儲。壓縮文件可以直接使用支持的NSW Homebrew標題安裝程序安裝。
該存儲庫的瑞士鏡子在https://gitlab.nicobosshard.ch/nicoboss/nsz下保持
如果Github擊倒NSZ,這將是新家。請添加書籤。
安裝此工具有幾種方法。您可以在下面找到所有安裝的詳細信息。
您需要在合適的目錄中使用HACTOOL兼容密鑰文件來使用此工具。
鍵文件必須在%USERPROFILE%/.switch/
(windows)/ $HOME/.switch/
(unix)或keys.txt
中的prod.keys
文件中。您必須合法獲取鑰匙!
您也可以使用Windows二進製文件。他們不需要安裝任何外部庫,並且可以在不安裝任何內容的情況下運行。您可以在發布頁面中找到二進製文件。
下面列出的方法要求您安裝Python 3.6+和PIP3。
使用以下命令安裝僅控制台的版本:
pip3 install --upgrade nsz
使用以下命令安裝GUI版本:
pip3 install --upgrade nsz[gui]
該工具也可以通過克隆存儲庫,安裝需求,然後使用python3 nsz.py
執行NSZ來運行該工具。
使用以下命令安裝僅控制台的版本要求:
pip3 install -r requirements.txt
使用以下命令安裝GUI版本要求:
pip3 install -r requirements-gui.txt
nsz.py --help
usage: nsz.py [-h] [-C] [-D] [-l LEVEL] [-L] [-B] [-S] [-s BS] [-V] [-Q] [-K]
[-F] [-p] [-P] [-t THREADS] [-m MULTI] [-o [OUTPUT]] [-w] [-r]
[--rm-source] [-i] [--depth DEPTH] [-x]
[--extractregex EXTRACTREGEX] [--titlekeys] [--undupe]
[--undupe-dryrun] [--undupe-rename] [--undupe-hardlink]
[--undupe-prioritylist UNDUPE_PRIORITYLIST]
[--undupe-whitelist UNDUPE_WHITELIST]
[--undupe-blacklist UNDUPE_BLACKLIST] [--undupe-old-versions]
[-c CREATE]
[file ...]
positional arguments:
file
options:
-h, --help show this help message and exit
-C Compress NSP/XCI
-D Decompress NSZ/XCZ/NCZ
-l LEVEL, --level LEVEL
Compression Level: Trade-off between compression speed
and compression ratio. Default: 18, Max: 22
-L, --long Enables zStandard long distance mode for even better
compression
-B, --block Use block compression option. This mode allows highly
multi-threaded compression/decompression with random
read access allowing compressed games to be played
without decompression in the future however this comes
with a slightly lower compression ratio cost. This is
the default option for XCZ.
-S, --solid Use solid compression option. Slightly higher
compression ratio but won't allow for random read
access. File compressed this way will never be
mountable (have to be installed or decompressed first
to run). This is the default option for NSZ.
-s BS, --bs BS Block Size for random read access 2^x while x between
14 and 32. Default: 20 => 1 MB
-V, --verify Verifies files after compression raising an unhandled
exception on hash mismatch and verify existing NSP and
NSZ files when given as parameter. Requires --keep
when used during compression.
-Q, --quick-verify Same as --verify but skips the NSP SHA256 hash
verification and only verifies NCA hashes. Does not
require --keep when used during compression.
-K, --keep Keep all useless files and partitions during
compression to allow bit-identical recreation
-F, --fix-padding Fixes PFS0 padding to match the nxdumptool/no-intro
standard. Incompatible with --verify so --quick-verify
will be used instead.
-p, --parseCnmt Extract TitleId/Version from Cnmt if this information
cannot be obtained from the filename. Required for
skipping/overwriting existing files and --rm-old-
version to work properly if some not every file is
named properly. Supported filenames:
*TitleID*[vVersion]*
-P, --alwaysParseCnmt
Always extract TitleId/Version from Cnmt and never
trust filenames
-t THREADS, --threads THREADS
Number of threads to compress with. Numbers < 1
corresponds to the number of logical CPU cores for
block compression and 3 for solid compression
-m MULTI, --multi MULTI
Executes multiple compression tasks in parallel. Take
a look at available RAM especially if compression
level is over 18.
-o [OUTPUT], --output [OUTPUT]
Directory to save the output NSZ files
-w, --overwrite Continues even if there already is a file with the
same name or title id inside the output directory
-r, --rm-old-version Removes older versions if found
--rm-source Deletes source file/s after compressing/decompressing.
It's recommended to only use this in combination with
--verify
-i, --info Show info about title or file
--depth DEPTH Max depth for file info and extraction
-x, --extract Extract a NSP/XCI/NSZ/XCZ/NSPZ
--extractregex EXTRACTREGEX
Regex specifying which files inside the container
should be extracted. Example: "^.*.(cert|tik)$"
--titlekeys Extracts titlekeys from your NSP/NSZ files and adds
missing keys to ./titlekeys.txt and JSON files inside
./titledb/ (obtainable from
https://github.com/blawar/titledb).
--undupe Deleted all duplicates (games with same ID and
Version). The Files folder will get parsed in order so
the later in the argument list the more likely the
file is to be deleted
--undupe-dryrun Shows what files would get deleted using --undupe
--undupe-rename Renames files to minimal standard:
[TitleId][vVersion].nsz
--undupe-hardlink Hardlinks files to minimal standard:
[TitleId][vVersion].nsz
--undupe-prioritylist UNDUPE_PRIORITYLIST
Regex specifying which dublicate deletion should be
prioritized before following the normal deletion
order. Example: "^.*.(nsp|xci)$"
--undupe-whitelist UNDUPE_WHITELIST
Regex specifying which dublicates should under no
circumstances be deleted. Example: "^.*.(nsz|xcz)$"
--undupe-blacklist UNDUPE_BLACKLIST
Regex specifying which files should always be deleted
- even if they are not even a dublicate! Be careful!
Example: "^.*.(nsp|xci)$"
--undupe-old-versions
Removes every old version as long there is a newer one
of the same titleID.
-c CREATE, --create CREATE
Inverse of --extract. Repacks files/folders to an NSP.
Example: --create out.nsp .in
nsz -C /path/to/folder/with/dumps/
nsz --verify -C /path/to/folder/with/dumps/
nsz --threads 8 --output /path/to/out/dir/ -C /path/to/folder/with/dumps/
nsz --level 22 -C /path/to/folder/with/dumps/
nsz -D /path/to/folder/with/dumps/
要查看每個標誌的所有可能標誌和描述,請檢查使用部分。
NSZ文件在功能上與NSP文件相同。他們的唯一目的是提醒用戶其中包含壓縮的NCZ文件。 NCZ文件可以與同一容器中的NCA文件混合。
作為此工具的替代方案,NSC_Builder還支持將NSP壓縮為NSZ,並將NSZ解壓縮到NSP。可以在https://github.com/julesontheroad/nsc_builder下載NSC_Builder
XCZ文件在功能上與XCI文件相同。他們的唯一目的是提醒用戶其中包含壓縮的NCZ文件。 NCZ文件可以與同一容器中的NCA文件混合。
這些是壓縮的NCA文件。 NCA被解密,然後使用Zstandard壓縮。
NCZ文件的第一個0x4000字節與原始NCA完全相同(並且仍然加密)。即使第一部分未始於0x4000,這也適用。
在0x4000時,有變量大小的NCZ標頭。它包含一個部分列表,這些部分告訴解壓縮後如何重新加入NCA數據。它還可以包含一個可選的塊壓縮標頭,允許隨機讀取訪問。
標題中的所有信息都可以從原始的NCA +票證中得出,但是預先提供的以使第三方盡可能容易地減壓。
直接在NCZ標頭之後,Zstandard流開始並在EOF處結束。該流將其解壓縮為偏移0x4000。如果使用塊壓縮,將流將流拆分為獨立塊,可以被解壓縮,如https://github.com/nicoboss/nsz/blob/master/master/nsz/blockdecompressrassorrader.py.py。壓縮框架[BlockId]不得超過解壓縮塊。如果較小,則必須對塊進行解壓縮。如果相等,則塊存儲在純文本中。
class Section :
def __init__ ( self , f ):
self . magic = f . read ( 8 ) # b'NCZSECTN'
self . offset = f . readInt64 ()
self . size = f . readInt64 ()
self . cryptoType = f . readInt64 ()
f . readInt64 () # padding
self . cryptoKey = f . read ( 16 )
self . cryptoCounter = f . read ( 16 )
class Block :
def __init__ ( self , f ):
self . magic = f . read ( 8 ) # b'NCZBLOCK'
self . version = f . readInt8 ()
self . type = f . readInt8 ()
self . unused = f . readInt8 ()
self . blockSizeExponent = f . readInt8 ()
self . numberOfBlocks = f . readInt32 ()
self . decompressedSize = f . readInt64 ()
self . compressedBlockSizeList = []
for i in range ( self . numberOfBlocks ):
self . compressedBlockSizeList . append ( f . readInt32 ())
nspf . seek ( 0x4000 )
sectionCount = nspf . readInt64 ()
for i in range ( sectionCount ):
sections . append ( Section ( nspf ))
if blockCompression :
BlockHeader = Block ( nspf )
NSZ PIP軟件包:https://pypi.org/project/nsz/
論壇線程:https://gbatemp.net/threads/nsz-homebrew-compatible-nsp-xci-compressor-decompressor.550556/
Sciresm的硬件加密功能;沒有此,在這裡實現的燃油安裝速度(50 MB/sec +)將是不可能的。
感謝我們的貢獻者:Nicoboss,Blawar,Plato79,Eughumer,Taorni,Anthonyu,Teknoraver,Kwottrich,Kwottrich,Gabest11,Siddhartha77,Alucryd,Seiya-Git,Seiya-Git,Drizzt,Drizzt,16Bitwonder,2weak2live,Thatch2live,Thatch, Maki-Chan,Maki-Chan,Maki-Chan,Maki-Chan,Maki-Chan,Pr0per,Pr0