public static void File2Titlekey(string inFile, Keyset keyset, Output Out) { var inFileExtension = Path.GetExtension(inFile).ToLower(); using (var inputFile = new FileStream(inFile, FileMode.Open, FileAccess.Read)) { switch (inFileExtension) { case ".nsp": var pfs = new PartitionFileSystem(inputFile.AsStorage()); ProcessNsp.GetTitlekey(pfs, keyset, Out); break; case ".xci": var xci = new Xci(keyset, inputFile.AsStorage()); ProcessXci.GetTitleKeys(xci, keyset, Out); break; case ".nspz": case ".xciz": var pfsz = new PartitionFileSystem(inputFile.AsStorage()); DecompressFs.GetTitleKeys(pfsz, keyset, Out); break; default: throw new NotImplementedException(); } } }
public void VerifyCompressedFolder(string nspFile) { var nspFileNoExtension = Path.GetFileNameWithoutExtension(nspFile); Out.Event($"Task VerifyCompressedFolder \"{nspFileNoExtension}\" started\r\n"); var keyset = ProcessKeyset.OpenKeyset(); using (var inputFile = new FileStream(nspFile, FileMode.Open, FileAccess.Read)) using (var inputFileStorage = inputFile.AsStorage()) { var pfs = new PartitionFileSystem(inputFileStorage); ProcessNsp.GetTitlekey(pfs, keyset, Out); var dirDecryptedReal = new DirectoryInfo(decryptedDir); var dirDecryptedRealCount = dirDecryptedReal.GetFiles().Length; cleanFolder(decryptedDir); var compressedFs = new LocalFileSystem(compressedDir); var decryptedFs = new LocalFileSystem(decryptedDir); DecompressFs.ProcessFs(compressedFs, decryptedFs, Out); UntrimDeltaNCA.Process(decryptedDir, pfs, keyset, Out); EncryptNCA.Encrypt(decryptedFs, null, true, keyset, Out); } Out.Event($"Task VerifyCompressedFolder \"{nspFileNoExtension}\" completed!\r\n"); }