如何使用IronZIP與Claude Code
經過更新的案件檔案能以正確的密碼打開,列出每個文件並乾淨地提取,依然保持舊的ZIP加密而非AES-256。文件列表中看不出變化。 Claude Code是Anthropic的編程代理,可從命令行、VS Code和JetBrains IDE中使用,也可以作為桌面應用程序和在瀏覽器中使用。 無論在哪裡運行,它都能讀取版本庫、編輯文件並運行shell命令,這使得它能夠階段性地更新存檔、提取它、讀取其原始目錄並在原件替換之前比較每個文件。
IronZIP從.NET打開、編輯並保存受密碼保護的ZIP文件,支持AES-128、AES-256或舊的傳統加密(也稱為ZipCrypto)。 每次編輯都是一次調用。 開啟檔案的調用、正確的文件如何替換舊的條目以及保存之前加密是否重新設置決定結果,任何一個選擇錯誤都不會拋出異常。 本頁其餘部分準備每日證據接收的Claude Code,包含四個測試過的提示和每個提示後的IronZIP行為。
兩個模型設置覆蓋整個會話。 Sonnet負責列表和項目規則,而opusplan別名使用Opus策劃更新器並使用Sonnet編寫。
快速開始從版本庫文件夾中啟動claude,並在此請求之前運行/model sonnet。
Add the IronZIP NuGet package, version 2026.10.2, to CaseArchive.csproj.
Then make Program.cs list every ZIP file under archives/:
- Apply the license key from IRONZIP_LICENSE_KEY before any other IronZIP call.
- Open each file as an IronZipArchive with the password from CASE_ARCHIVE_PASSWORD.
- Print a block per archive with its entry count, then each entry's name, size and IsCrypted value.
- If an archive won't open, print its exception message and move on to the next one.
Don't change any archive.
Don't print or echo the value of either variable. Tell me whether each one is set.
預計CASE-1043即使使用正確的密碼也會失敗。 現有ZIP的開啟部分解釋了原因。
最小工作流程(5 個步驟)
- 從 NuGet 下載 C# ZIP 程式庫
- 在版本庫中啟動Claude Code並選擇一個模型使用/model
- 將IronZIP的更新規則放入CLAUDE.md中並創建一個無法編輯的審核子代理
- 在計劃模式中計劃更新器,每個新存檔都在存檔文件夾之外階段性進行
- 提取每個階段性存檔,比較其文件並讀取其目錄後再替換原件
Claude Code在.NET存檔專案中做什麼?
Claude Code編寫更新器,構建每個階段存檔,解包它,讀取其目錄並列出未通過的檢查。 在檢查失敗後,它會編輯代碼並重新運行整個接收。 您的角色是定義每個案件存檔必須包含的內容並在最後閱讀報告。
在第一個提示中將IronZIP命名為唯一的存檔程式庫。 攻擊者在AI編程工具出現幻覺時發佈惡意包,一個能選自包的代理可以安裝其中之一。 這種攻擊稱為slopsquatting。
您如何設置Claude Code?
Anthropic的快速入門指南涵蓋了安裝Claude Code和簽到。 一個運行中的安裝會列印claude --version的版本號碼。
如何設立一個Claude Code可以工作的項目?
測試版本庫CaseArchive是一個.NET 9控制台專案,在存檔文件夾中包含三個AES-256案件存檔,兩者的新文件在來的文件夾中,Markdown頁面在文檔文件夾中設定傳入規則。 添加一個新文件名,用匹配的名稱替換它的條目,remove.txt中列出的名字會被移除,而若某個案件沒有來的文件夾則保持不變。 存檔密碼來自CASE_ARCHIVE_PASSWORD。
在每個會話開始時加載在CLAUDE.md中編寫的規則。 在快速入門後,放置好包後,下一個請求將寫入該文件和一位審查員。
Create CLAUDE.md in the repo root with a "Case archives" heading.
Put these rules under it for future sessions:
- Archives are read and written with IronZIP and nothing else.
- The IronZIP package stays at the version CaseArchive.csproj references now.
- The intake rules live in docs/case-archives.md.
- Look up an IronZIP member in docs/IronZip.xml before you use it.
- The XML has no entry for IronZip.Entry. Its Name, Size and IsCrypted exist anyway.
- A file replaces an archive under archives/ after it has passed every check, never before.
- CASE_ARCHIVE_PASSWORD and IRONZIP_LICENSE_KEY values never appear in output, logs or files.
Copy docs/IronZip.xml now from the local NuGet cache folder for that IronZIP version.
If the cache has no such file, stop and tell me.
Then create .claude/agents/archive-auditor.md.
Give it frontmatter with the name archive-auditor, a one-line description and a tools field.
The tools field lists Read, Grep and Glob, so the auditor can't edit.
In its instructions, tell it to:
- collect the IronZIP types and members used under Services/
- flag any member that docs/IronZip.xml lacks, and list Entry members separately
- point out each save of an opened archive that doesn't set the encryption again first
運行中的Claude Code會話不會檢測到新創建的.claude/agents文件夾,因此在開始前將其提交並包含一個佔位文件。
在第一次打開之前設置授權。 沒有密鑰,打開和提取都會引發LicensingException,訊息顯示“需要生產授權”。 IRONZIP_LICENSE_KEY變數本身無法授權IronZIP。在校準的探測中變數已設置但License.IsLicensed仍然為false,因此程序從中分配IronZip.License.LicenseKey。 IronZIP授權金鑰頁面說明如何獲取密鑰及在哪裡設置。
哪些IronZIP更新規則屬於CLAUDE.md?
校準探針在IronZIP 2026.10.2上對每一行進行測量,與固定存檔和匹配探針存檔相比,請將塊粘貼在案件存檔標題下,然後重新啟動claude --continue以便會話讀取它。
Measured on IronZIP 2026.10.2, these rules apply to every archive update:
- Open with new IronZipArchive(path, password) or IronZipArchive.FromArchive(path, password).
- IronZipArchive.FromFile(path) builds a new archive that stores the ZIP file itself as one entry.
- A protected archive with exactly one entry does not open.
- The constructor and FromArchive throw "Invalid Password!" with the right password.
- ExtractArchiveToDirectory reads it, so rebuild it from an extracted copy in a new IronZipArchive.
- Saving an opened archive writes every entry with the Traditional cipher.
- Call Encrypt(password, EncryptionMethods.AES256) before the save to keep AES-256.
- Entries() reports IsCrypted true either way.
- Opening does not check the password. The save does.
- Entries() lists an archive opened with a wrong password, and SaveAs then throws ZipException.
- Add stores the file name without its folder.
- Adding a name the archive already holds keeps both entries, and extraction writes the later one.
- ReplaceEntry(name, path) stores the new entry under the path it is given, folders included.
- Replace an entry with Delete(name) and then Add(path).
- Delete and ReplaceEntry throw for a name the archive does not hold. Test Contains(name) first.
- Add throws UnauthorizedAccessException for a folder. Add files one at a time.
- Save() writes back over the file the archive was opened from.
為什麼更新的存檔會失去AES-256加密?
當沒有再次設置方法時,保存會回退到傳統加密。 在我們的校準探針中,用密碼打開CASE-1044並在無任何更改的情況下保存它將所有三個條目都寫入傳統加密。 Python的標準zipfile模組無法讀取AES條目,然後用密碼解密了每一個。 在保存之前調用Encrypt與EncryptionMethods.AES256保持了更新CASE-1042的所有五個條目在AES-256,包括三個新條目。 一個命名AES-256的ZipSaveOptions,傳遞給保存調用,對刪除一個條目的存檔同樣有效。
無論哪種方式,用密碼提取都成功,因此只有原始目錄顯示降級。 每個AES條目帶有額外的字段0x9901,其強度字節為256位密鑰的3,而標準條目在探針中無此字段。
如何用IronZIP打開現有的ZIP?
將路徑和密碼傳遞給構造函數。 添加文件到ZIP示例打開了其存檔而用FromFile,並在生成一個包含CASE-1042.zip的存檔探針中作為一個未加密的條目,旁邊是添加的照片。 IronZIP的skill.md警告FromFile總是構建新存檔,並將構造函數和FromArchive作為開啟調用。
一個含有單個受保護條目的存檔需要不同的方法。 在探針中,這種類型的AES-256存檔從構造函數FromArchive和字節數組構造函數中拋出了“無效的密碼!”,而使用相同密碼的提取工作。 傳統存檔構造函數對一個條目丟出了相同的錯誤。 重建將存檔解壓縮到一個臨時文件夾中,將新進入的文件複製進去,並在首先調用Encrypt時保存一個新存檔。重建的CASE-1043持有三個AES-256條目,並在後續正常打開。
如何提示IronZIP代碼才可編譯?
運行/model opusplan,然後循環Shift+Tab直到狀態欄出現計劃模式,然後發送請求。
Build the monthly intake in Services/IntakeUpdater.cs and Services/ArchiveCheck.cs.
Program.cs runs both after the listing.
IntakeUpdater applies @docs/case-archives.md to each case folder under incoming/:
- It writes out/staged/<case id>.zip with AES-256 and the same password.
- It leaves archives/ untouched.
- A case without an incoming folder keeps its archive byte for byte.
ArchiveCheck judges a staged archive without trusting IronZIP's listing:
1. Extract both archives with IronZIP and the password into new temp folders.
2. Compare each staged entry's SHA-256 with its source.
3. Parse the staged file's central directory bytes itself, without decrypting.
A case fails on any of these:
- a repeated entry name
- an entry without AES extra field 0x9901 at key strength 3
- staged names that differ from the expected set
An added or replaced entry's source is the incoming file.
A kept entry's source is its extracted original.
The expected set is the original names minus those in remove.txt, plus incoming names.
Leave out remove.txt itself.
Move a passing case's staged file over the original.
Use a plain file move, not a second IronZIP save.
A second intake on the same incoming files must pass and leave the same entries.
Write out/intake-report.csv with one row per case:
- entries before and after
- names added, replaced and removed
- pass or fail, with the reason
Print how many cases pass.
Only the directory parse may read an archive without IronZIP.
Don't add another package.
When all cases pass, have @agent-archive-auditor review Services/.
每個提示中的檢查阻止不同的錯誤通過。
- 對來源的哈希:一個替換的條目與其進入的文件比較,因此保持其舊文本的聲明失敗。
- 目錄解析:重複的名稱和缺失的條目也未被檢測到提取。
- 首先階段:一個檢查失敗的更新仍保留原先的存檔不變。
Encrypt,從提取的副本重建CASE-1043,並且無法兩次存儲替換的名稱,要麼是因為它先刪除舊條目,要麼因為它從頭開始構建每個分段存檔。 缺少任何這些的計劃仍然正確列出保存的存檔。錯誤的密碼會損壞案件存檔嗎?
IronZIP列示以任何密碼打開的AES保護存檔,因此第一個錯誤晚到。 在校準探針中保存拋出了ZipException(“AES的無效密碼”)且未寫入文件,提取拋出ArgumentException(“無效密碼!!”)。 最後的提示讓代理證明這條路徑使原件保持不變。
Prove a wrong archive password can't damage anything, in these steps:
1. Hash every file under archives/ with SHA-256.
2. Launch the built program a second time, in a child process.
3. Hash the files again once the child exits.
4. Print both hash lists side by side.
5. Print the child's exit code and the failure reasons it wrote to out/intake-report.csv.
The child inherits IRONZIP_LICENSE_KEY and gets a wrong CASE_ARCHIVE_PASSWORD.
It also gets a --child flag, under which it starts no process.
Three things have to hold:
- Every hash matches.
- The report has a failed row for CASE-1042 and one for CASE-1043, each with IronZIP's error text.
- The exit code is non-zero.
Change the program only where one of those fails, then run the check again.
在實際運行中,這些提示產生了什麼結果?
Claude Code在單一會話中依次接收四個提示,且規則塊在第三個提示之前附加到CLAUDE.md。 運行後,提交的代碼從一個乾淨的克隆重建並在原始存檔對應運行。 不含IronZIP共用的任何代碼的Python庫pyzipper讀取了每一個結果。
- Quickstart清單,由Claude Code本身運行,顯示CASE-1042中的4個加密條目,CASE-1044中的3個以及CASE-1043的“無效密碼!”。
- 接收後,CASE-1042持有5個條目而非4個。
- CASE-1042更新添加了兩張照片,替換了證人聲明並移除了invoice-7781.pdf。
- CASE-1043從1個條目到3個。
- CASE-1044保留了每一字節。
- 三個存檔中所有11個條目都使用AES-256。
- 每個條目與其源文件的SHA-256匹配。
- 計劃從提取副本中構建每個階段性存檔,包括單條目CASE-1043,且從未打開存檔進行編輯。
- 加密在更新器的唯一保存前運行。
- 目錄分析器讀取每個條目的名字和AES強度字節,不讀取大小。
- 在第三個提示結束時,存檔檢查子代理運行一次,並未報告未記載的IronZIP成員。
- 乾淨地重新建構以2.1秒通過了包括來的文件的兩個案例,並報告CASE-1044被跳過。
- 重建中的條目與運行中的匹配。
- 密碼錯誤的情況下,三個案例都在提取時失敗,報顯“無效密碼!!”。
- 在錯誤的密碼運行中,存檔哈希沒有改變,進程以代碼1退出。
- 在第四個提示之前,錯誤的密碼在第一次提取時停滯未處理的例外並無報告,哈希仍匹配。
- 一些步驟與頁面上運行的不同。 所有提示均無人值守發送,作為恢復的無頭會話,因此/model選擇以命令行選項傳遞,每個新提示均重新加載CLAUDE.md而無需手動重啟。 在該模式中無法使用計劃對話框,因此計劃通過打字回覆批准。 第四個提示的證明以shell指令形式運行,因此程序沒有獲得子進程代碼並且從未讀取子標誌。 在第四個提示期間,Claude Code同樣以正確的密碼運行了接收一次,並以相同的條目重寫CASE-1042和CASE-1043。
Cursor指南也在任何文件更改之前進行規劃,並在其運行中規劃模式將IronZIP端口保存為可編輯的Markdown計劃。 在ChatGPT Codex指南中,接收規則寫入AGENTS.md,這是Codex在任何工作開始之前加載的文件,而本指南使用CLAUDE.md。 AI編程助手指南設置了一個完整的IronZIP任務,使用固定的通過清單,並且共享的運行紀錄列出Claude Code版本、模型、提示計時及這些結果背後的測試機器。
疑難排解
- 如果打開第一個存檔時引發授權異常,即IronZIP授權金鑰
- 如果受保護的存檔拒絕其密碼,即訪問受保護的ZIP
- 如果案件存檔超出經典ZIP限制,即IronZIP文件和存檔大小限制
問題?
如果您有任何疑問,請聯繫support@ironsoftware.com
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。