SmallBin is a lightweight, secure file storage library for .NET that enables storing multiple files in a single encrypted container with metadata support and comprehensive logging capabilities.
- Single-file encrypted database
- Password-based encryption (AES-256)
- File metadata and tagging
- File compression support
- Search functionality
- Thread-safe operations
- Flexible logging system with console and file output
- Extensible logging interface
dotnet add package SmallBin
using SmallBin;
using SmallBin.Logging;
// Optional: Configure logging
var logger = new ConsoleLogger(); // or new FileLogger("app.log")
// Create or open an encrypted database using the builder pattern
using var db = SecureFileDatabase.Create("mydata.sdb", "password123")
.WithoutCompression() // Optional: disable compression (enabled by default)
.WithAutoSave() // Optional: enable auto-save (disabled by default)
.WithLogger(logger) // Optional: add logging support
.Build();
// The builder pattern makes it clear which options are being configured
// and allows for future extensibility without breaking changes
// Add a single file with tags
db.SaveFile("document.pdf",
tags: new List<string> { "work", "reports" },
contentType: "application/pdf");
// Add multiple files
foreach (string file in Directory.GetFiles("source", "*.jpg"))
{
db.SaveFile(file,
tags: new List<string> { "photos" },
contentType: "image/jpeg");
}
// Get file by ID
byte[] fileContent = db.GetFile(fileId);
File.WriteAllBytes("exported.pdf", fileContent);
// Search by filename
var criteria = new SearchCriteria { FileName = "report" };
var files = db.Search(criteria);
// Search by tags
var photoFiles = db.Search(new SearchCriteria
{
Tags = new List<string> { "photos" }
});
db.UpdateMetadata(fileId, entry =>
{
entry.Tags.Add("important");
entry.CustomMetadata["author"] = "John Doe";
entry.ContentType = "application/pdf";
});
db.DeleteFile(fileId);
// Console logging
var consoleLogger = new ConsoleLogger();
// File logging
var fileLogger = new FileLogger("app.log");
// Custom logging by implementing ILogger
public class CustomLogger : ILogger
{
public void Log(string message)
{
// Custom logging implementation
}
}
// Using multiple loggers
var db = SecureFileDatabase.Create("mydata.sdb", "password123")
.WithLogger(consoleLogger)
.WithLogger(fileLogger)
.Build();
// Console logging
var consoleLogger = new ConsoleLogger();
// File logging
var fileLogger = new FileLogger("app.log");
// Custom logging by implementing ILogger
public class CustomLogger : ILogger
{
public void Log(string message)
{
// Custom logging implementation
}
}
// Using multiple loggers
var db = SecureFileDatabase.Create("mydata.sdb", "password123")
.WithLogger(consoleLogger)
.WithLogger(fileLogger)
.Build();
public partial class MainWindow : Window
{
private SecureFileDatabase _db;
private ILogger _logger;
private void OpenDatabase()
{
_logger = new FileLogger("app.log");
_db = SecureFileDatabase.Create("data.sdb", "password123")
.WithAutoSave() // Enable auto-save for WPF applications
.WithLogger(_logger)
.Build();
}
private void AddFile_Click(object sender, RoutedEventArgs e)
{
var dialog = new OpenFileDialog { Multiselect = true };
if (dialog.ShowDialog() == true)
{
foreach (string filename in dialog.FileNames)
{
_db.SaveFile(filename);
}
}
}
}
- Passwords should be strong and securely stored
- Database files contain encrypted content
- Each file has its own encryption IV
- Uses PBKDF2 for key derivation
- All operations are logged for security auditing
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions welcome! NEVER submit pull requests directly to the main branch.
Type | Version Change | When to Use |
---|---|---|
breaking: |
MAJOR (1.0.0) | Incompatible API changes, removing features |
major: |
MAJOR (1.0.0) | Same as breaking |
feat: |
MINOR (0.1.0) | New features, capabilities, or enhancements |
fix: |
PATCH (0.0.1) | Bug fixes, correcting behavior |
refactor: |
PATCH | Code restructuring without behavior change |
chore: |
PATCH | Build process, dependencies, tooling |
style: |
PATCH | Code formatting, naming (no logic change) |
test: |
PATCH | Adding/modifying tests |
docs: |
NONE | Documentation only |
ci: |
NONE | CI/CD changes |
breaking: remove support for XML config files
feat: add dark mode theme support
fix: prevent crash when user input is empty
chore: update NuGet packages
refactor: simplify login logic
style: fix code indentation
test: add unit tests for auth service
docs: update API documentation
ci: add new deploy stage
- Use present tense ("add feature" not "added feature")
- Keep first line under 70 characters
- Add scope for clarity:
feat(auth):
,fix(db):
- Include ticket number if needed:
feat: add login (#123)
If you find this project useful, please consider giving it a star on GitHub!