https://github.com/zalza13/litedb.versionchecker
Detects if a `.db` file was created with LiteDB 4 or LiteDB 5 using binary header analysis.
https://github.com/zalza13/litedb.versionchecker
database-tools dotnet file-inspector litedb litedb-database version-checker
Last synced: 4 months ago
JSON representation
Detects if a `.db` file was created with LiteDB 4 or LiteDB 5 using binary header analysis.
- Host: GitHub
- URL: https://github.com/zalza13/litedb.versionchecker
- Owner: zalza13
- Created: 2025-04-09T17:14:56.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-04-09T17:47:51.000Z (6 months ago)
- Last Synced: 2025-04-11T15:58:34.466Z (6 months ago)
- Topics: database-tools, dotnet, file-inspector, litedb, litedb-database, version-checker
- Language: C#
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LiteDb.VersionChecker
๐ Simple and reliable utility to detect if a `.db` file was created with **LiteDB 4** or **LiteDB 5** โ without trying to open the file.
> ๐ง Based on the actual internal logic used by LiteDB to determine file structure versions (`FileReaderV7`, `FileReaderV8`, etc.).
## โจ Features
- โ Detects LiteDB 4 files (datafile version 7)
- โ Detects LiteDB 5 files (datafile version 8)
- โ Works even on encrypted LiteDB 5 files
- โ Zero dependencies
- โ .NET Standard 2.0+ / .NET 6+ compatible## ๐ Installation
If published as a NuGet package:
```bash
dotnet add package LiteDb.VersionChecker
```Otherwise, just copy the class from `LiteDbVersionDetector.cs` into your project.
## ๐งช Usage
```csharp
string version = LiteDbVersionDetector.DetectLiteDbVersion("mydata.db");
Console.WriteLine($"Detected version: {version}");
```### Output:
```
LiteDB 4
LiteDB 5
No LiteDB file
```## ๐ How it works
LiteDB stores internal metadata at fixed offsets inside the first 1024 bytes of the file.
This library reads:
- A special header string: `** This is a LiteDB file **`
- A version byte:
- `7` โ LiteDB 4
- `8` โ LiteDB 5
- Encrypted LiteDB 5 files are detected by checking `buffer[0] == 1`## ๐ File structure detection
| Version | Offset | Value |
|----------|---------|---------------------------------|
| Header | 25 (v4) / 32 (v5) | `** This is a LiteDB file **` |
| Version | 52 (v4) / 59 (v5) | `7` or `8` |
| Encrypted| 0 | `1` if file is encrypted (v5+) |## ๐ License
MIT โ Free for personal and commercial use.
---
Contributions welcome! If LiteDB won't merge it, let's improve it together here ๐