Skip to content

Commit 998fef4

Browse files
authored
Implement new security features and more functions. (#1)
* Add and update workflow. * Implement password and chunk hash. * Update console app. * Update model and core classes. * Implement new methods and directory support. * Updated example * Update documentation.
1 parent ade2391 commit 998fef4

16 files changed

Lines changed: 679 additions & 216 deletions

File tree

.github/workflows/filo-package.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ jobs:
4545
--api-key "${{ secrets.NUGET_KEY }}" `
4646
--skip-duplicate
4747
# ── Publish to GitHub Packages ─────────────────────────────────
48-
# GITHUB_TOKEN is automatically available + has package:write permission
4948
dotnet nuget push "$nupkg" `
5049
--source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" `
5150
--api-key "${{ secrets.GITHUB_TOKEN }}" `

.github/workflows/filo.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Ytdlp.NET
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: windows-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v4
18+
with:
19+
dotnet-version: 10.0.x
20+
- name: Restore dependencies
21+
run: dotnet restore src/Filo/Filo.csproj
22+
- name: Build
23+
run: dotnet build src/Filo/Filo.csproj -c Release

README.md

Lines changed: 83 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,35 @@
55
![NuGet Downloads](https://img.shields.io/nuget/dt/Filo)
66
![Visitors](https://visitor-badge.laobi.icu/badge?page_id=manusoft/FiloContainer)
77

8-
---
9-
108
<img width="512" height="512" alt="FILO" src="https://github.com/user-attachments/assets/d26100b0-2d96-480c-80b1-3e6501ebcd33" />
119

10+
## FILO v1.1 Highlights
11+
12+
**Added:**
13+
14+
* ✔ Chunk integrity hashing (SHA256)
15+
* ✔ Password-based encryption (PBKDF2)
16+
17+
**Deprecated:**
18+
19+
*`WithEncryption(byte[] key)` — use `WithPassword(string password)` instead.
20+
21+
---
1222

1323
## Overview
1424

15-
**FILO** (Files In, Layered & Organized) is a modern **multi-file container format** for .NET designed to handle **large files efficiently**.
25+
**FILO** (Files In, Layered & Organized) is a modern **multi-file container format** for .NET designed for **large files**.
1626
It stores multiple files (video, audio, text, binaries, etc.) in a **single container**, supporting:
1727

18-
- **Large files** (videos, audio, binaries)
19-
- **Multiple files per container**
20-
- Chunked streaming for **GB-sized files**
21-
- AES256 optional encryption per chunk
22-
- Metadata storage
23-
- File checksums for integrity
24-
- Fully async and memory-efficient operations
28+
* **Large files** (GB-sized videos, audio, binaries)
29+
* **Multiple files per container**
30+
* **Chunked streaming** for memory-efficient reads
31+
* **AES256 optional encryption per chunk**
32+
* **Embedded metadata**
33+
* **File checksums** for integrity
34+
* Fully **async APIs**
2535

26-
> FILO = **Files In, Layered & Organized**
27-
28-
It is ideal for **video/audio streaming, backup containers, and custom file packaging**.
36+
> FILO = **Files In, Layered & Organized** — ideal for **video/audio streaming, backups, and custom file packaging**.
2937
3038
---
3139

@@ -106,7 +114,7 @@ Traditional ZIP or JSON-based storage has limitations:
106114
Install via NuGet:
107115

108116
```bash
109-
dotnet add package Filo.1.0.0
117+
dotnet add package Filo --version 1.1.0
110118
````
111119

112120
---
@@ -117,15 +125,14 @@ dotnet add package Filo.1.0.0
117125

118126
```csharp
119127
using Filo;
120-
using System.Security.Cryptography;
121128
122-
var key = RandomNumberGenerator.GetBytes(32); // AES256 key
129+
var pwd = "mypassword";
123130
124131
var writer = new FiloWriter("backup.filo")
125132
.AddFile("video.mp4", new FileMetadata { MimeType = "video/mp4" })
126133
.AddFile("subtitle.srt", new FileMetadata { MimeType = "text/plain" })
127134
.WithChunkSize(5_000_000)
128-
.WithEncryption(key);
135+
.WithPassword(pwd);
129136
130137
await writer.WriteAsync();
131138
Console.WriteLine("FILO container created!");
@@ -137,73 +144,90 @@ Console.WriteLine("FILO container created!");
137144
var reader = new FiloReader("backup.filo");
138145
await reader.InitializeAsync();
139146
140-
// List files in container
147+
var key = reader.DeriveKey("mypassword");
148+
149+
// List files
141150
foreach (var file in reader.ListFiles())
142151
Console.WriteLine(file);
143152
144-
// Stream a file (AES256 encrypted example)
153+
// Stream chunks
145154
await foreach (var chunk in reader.StreamFileAsync("video.mp4", key))
146155
{
147-
// Process chunk
156+
await chunk.WriteAsync(chunk);
148157
}
149158
```
150159
151160
---
152161
153-
## Streaming Video/Audio
162+
### Direct Streaming
154163
155-
FILO supports **direct streaming without reassembling the file**:
164+
```csharp
165+
using var stream = reader.OpenStream("video.mp4", key);
166+
await stream.CopyToAsync(outputFile);
167+
```
168+
169+
### Extract Files Using `FiloStream`
156170
157171
```csharp
158-
await using var filoStream = new FiloStream(reader, "video.mp4", key);
159-
await using var output = new FileStream("video_streamed.mp4", FileMode.Create);
172+
using var filoStream = new FiloStream(reader, "video.mp4", key);
173+
using var output = File.Create("video_restored.mp4");
174+
160175
await filoStream.CopyToAsync(output);
176+
Console.WriteLine("File extracted!");
177+
```
178+
179+
### Load Image
180+
181+
```csharp
182+
using var stream = new FiloStream(reader, "photo.jpg");
183+
using var image = System.Drawing.Image.FromStream(stream);
184+
185+
Console.WriteLine($"Loaded image: {image.Width}x{image.Height}");
186+
161187
```
162188
163-
### In Blazor Server / ASP.NET Core
189+
## Streaming Video/Audio in ASP.NET Core / Blazor
164190
165191
```csharp
166-
[HttpGet("video/{fileName}")]
167-
public async Task<IActionResult> StreamVideo(string fileName)
192+
public async Task<IActionResult> GetVideo()
168193
{
169-
var reader = new FiloReader("backup.filo");
194+
var reader = new FiloReader("media.filo");
170195
await reader.InitializeAsync();
171-
var filoStream = new FiloStream(reader, fileName, key: YourKeyHere);
172196
173-
return File(filoStream, "video/mp4", enableRangeProcessing: true);
197+
var key = reader.DeriveKey("password");
198+
var stream = new FiloStream(reader, "movie.mp4", key);
199+
200+
return File(stream, "video/mp4");
174201
}
175202
```
176203
177-
* Supports **large files**, **streaming**, and **AES256 encrypted chunks**
178-
* Browser can **seek**, **pause**, and **resume** seamlessly
204+
> Supports **large files**, **streaming**, and **AES256 encrypted chunks**. Browser can **seek, pause, and resume** seamlessly.
179205
180206
---
181207
182-
## Multi-file container
183-
184-
You can store multiple files in the same container:
208+
## Multi-file Container Example
185209
186210
```csharp
187211
var writer = new FiloWriter("media.filo")
188212
.AddFile("movie.mp4", new FileMetadata { MimeType = "video/mp4" })
189213
.AddFile("audio.mp3", new FileMetadata { MimeType = "audio/mpeg" })
190214
.AddFile("subtitle.srt", new FileMetadata { MimeType = "text/plain" })
191215
.WithChunkSize(10_000_000)
192-
.WithEncryption(key);
216+
.WithPassword("mypassword");
193217
194218
await writer.WriteAsync();
195219
```
196220
197-
* The container will store **indexes, metadata, and checksums**.
198-
* You can **stream each file individually** using `FiloStream` or `StreamFileAsync`.
221+
* Stores **indexes, metadata, and checksums**
222+
* Stream **each file individually** using `FiloStream` or `StreamFileAsync`
199223
200224
---
201225
202226
## Chunked Streaming
203227
204-
* FILO reads files in **chunks** to minimize memory usage.
205-
* Suitable for **large video/audio files**.
206-
* Supports **AES256 encryption per chunk**.
228+
* Reads files in **memory-efficient chunks**
229+
* Ideal for **large video/audio files**
230+
* Supports **AES256 encryption per chunk**
207231
208232
```csharp
209233
await foreach (var chunk in reader.StreamFileAsync("largevideo.mp4", key))
@@ -212,31 +236,41 @@ await foreach (var chunk in reader.StreamFileAsync("largevideo.mp4", key))
212236
}
213237
```
214238
215-
> Always verify checksum for **large file integrity**.
239+
---
240+
241+
## ⚡ When to Use FiloStream vs StreamFileAsync
242+
243+
| Method | Best For |
244+
| ------------------| ---------------- |
245+
| StreamFileAsync() | chunk processing |
246+
| FiloStream normal | file streaming |
247+
| CopyToAsync() | extraction |
248+
| HTTP streaming | media servers |
216249
217250
---
218251
219-
## Checksums & Integrity
252+
> Always verify checksum for **large file integrity**.
253+
220254
221-
FILO stores **SHA256 checksums** for each file:
255+
## Checksums & Integrity
222256
223257
```csharp
224258
var checksum = await FiloChecksum.ComputeFileSHA256Async("video.mp4");
225259
Console.WriteLine(checksum);
226260
```
227261
228-
You can verify that **streamed files match the original**.
262+
* Ensures **streamed files match the original**
229263
230264
---
231265
232266
## Fluent API Summary
233267
234268
| Class | Key Methods |
235269
| ------------------ | ---------------------------------------------------------------------- |
236-
| `FiloWriter` | `.AddFile()`, `.WithChunkSize()`, `.WithEncryption()`, `.WriteAsync()` |
237-
| `FiloReader` | `.InitializeAsync()`, `.ListFiles()`, `.StreamFileAsync()` |
238-
| `FiloStream` | `.ReadAsync()` – supports streaming directly to players |
239-
| `FiloChecksum` | `.ComputeFileSHA256Async()`, `.ComputeFileSHA256Async()`, `.ComputeSHA256()`, `.Verify()`,`.VerifyFileAsync()` |
270+
| `FiloWriter` | `.AddFile()`, `AddDirectory()`, `.WithChunkSize()`, `.WithPassword()`, `.WriteAsync()` |
271+
| `FiloReader` | `.InitializeAsync()`, `DeriveKey()`, `FileExists()`, `GetFileInfo()`, `.ListFiles()`, `.StreamFileAsync()`, `OpenStream()`, `ExtractFileAsync()`, `ExtractDirectoryAsync()`, `ReadHeaderAsync()` |
272+
| `FiloStream` | `.ReadAsync()` – supports streaming directly to players, `Read()` |
273+
| `FiloChecksum` | `.ComputeSHA256()`, `.ComputeSHA256Async()`, `.ComputeFileSHA256Async()`, `.ComputeFileSHA256Async()`,`.Verify()`, `VerifyFileAsync()` |
240274
| `FiloEncryption` | `.Encrypt()`, `.Decrypt()` |
241275
242276
---

0 commit comments

Comments
 (0)