Update readme
This commit is contained in:
125
README.md
125
README.md
@@ -1,16 +1,18 @@
|
||||
# DataLiteC Package
|
||||
# DataLiteC
|
||||
|
||||
**DataLiteC** is a Swift package that provides a system interface to the SQLite C library. It supports **macOS**, **iOS**, and **Linux** platforms, using the system SQLite library via `pkg-config`.
|
||||
**DataLiteC** is a Swift package that provides low-level access to an embedded, fully-encrypted SQLite engine. It includes [SQLCipher](https://github.com/sqlcipher/sqlcipher) and [LibTomCrypt](https://github.com/libtom/libtomcrypt) as source dependencies, with no external installation required.
|
||||
|
||||
## Overview
|
||||
|
||||
DataLiteC is a Swift system library wrapper that links directly to the SQLite C API. It does not add any abstractions and enables direct usage of SQLite's C functions within Swift code.
|
||||
**DataLiteC** provides direct access to the C API of SQLCipher, a fully encrypted drop-in replacement for SQLite. It is designed for Swift projects that require precise, low-level control over encrypted database operations without relying on system-installed libraries.
|
||||
|
||||
The package statically includes both SQLCipher and LibTomCrypt as source code, making it fully self-contained and portable across **macOS**, **iOS**, and **Linux** platforms.
|
||||
|
||||
DataLiteC does not introduce any abstractions or Swift-specific layers — it simply exposes the raw C interface, allowing complete control and maximum compatibility with the underlying engine.
|
||||
|
||||
## Installation
|
||||
|
||||
### Adding DataLiteC to Your Project
|
||||
|
||||
To use DataLiteC in your Swift project, add it to the dependencies section of your `Package.swift` file:
|
||||
To add **DataLiteC** to your project, include it in the `dependencies` section of your `Package.swift` file:
|
||||
|
||||
```swift
|
||||
// swift-tools-version: 5.10
|
||||
@@ -20,38 +22,21 @@ import PackageDescription
|
||||
let package = Package(
|
||||
name: "YourProject",
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/angd-dev/data-lite-c.git", from: "1.0.0")
|
||||
.package(url: "https://github.com/angd-dev/data-lite-c.git", from: "2.0.0")
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "YourTarget",
|
||||
dependencies: [
|
||||
.target(name: "YourTarget", dependencies: [
|
||||
.product(name: "DataLiteC", package: "data-lite-c")
|
||||
]
|
||||
)
|
||||
])
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
### System Requirements
|
||||
|
||||
DataLiteC requires SQLite to be installed on your system:
|
||||
|
||||
- **Linux**: Install `sqlite3` and development headers:
|
||||
|
||||
```bash
|
||||
sudo apt-get install sqlite3 libsqlite3-dev
|
||||
```
|
||||
|
||||
- **macOS**: Install SQLite using Homebrew:
|
||||
|
||||
```bash
|
||||
brew install sqlite
|
||||
```
|
||||
No additional setup or system packages are required — all dependencies are bundled and built automatically.
|
||||
|
||||
## Usage
|
||||
|
||||
Once the package is added, you can import it and use SQLite's C API directly:
|
||||
Once the package is added, you can import `DataLiteC` and use the raw SQLCipher C API directly in Swift:
|
||||
|
||||
```swift
|
||||
import DataLiteC
|
||||
@@ -65,20 +50,86 @@ if sqlite3_open(":memory:", &db) == SQLITE_OK {
|
||||
}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
To use encryption with SQLCipher, set the encryption key immediately after opening the database:
|
||||
|
||||
If you encounter build errors such as missing `sqlite3.h`, ensure that `pkg-config` can locate SQLite:
|
||||
```swift
|
||||
if sqlite3_open("secure.db", &db) == SQLITE_OK {
|
||||
let key = "your-secret-passphrase"
|
||||
sqlite3_key(db, key, Int32(key.utf8.count))
|
||||
|
||||
```bash
|
||||
pkg-config --cflags sqlite3
|
||||
```
|
||||
// It's good practice to verify key correctness
|
||||
if sqlite3_exec(db, "SELECT count(*) FROM sqlite_master;", nil, nil, nil) == SQLITE_OK {
|
||||
print("Successfully opened encrypted database.")
|
||||
} else {
|
||||
print("Invalid encryption key or corrupted database.")
|
||||
}
|
||||
|
||||
If the command returns nothing, manually set the `PKG_CONFIG_PATH`:
|
||||
|
||||
```bash
|
||||
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
sqlite3_close(db)
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
### DataLiteC
|
||||
|
||||
This project is licensed under the MIT License. See the `LICENSE` file for details.
|
||||
|
||||
### SQLCipher
|
||||
|
||||
```
|
||||
Copyright (c) 2025, ZETETIC LLC
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the ZETETIC LLC nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
```
|
||||
|
||||
### LibTomCrypt
|
||||
|
||||
```
|
||||
The LibTom license
|
||||
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user