Skip to content

Provides transparent 256-bit AES full database encryption

License

Notifications You must be signed in to change notification settings

wlltmrt/sqlcipher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQLCipher

Build Status Swift 5 Version Software License Swift Package Manager Compatible

A framework provides transparent 256-bit AES full database encryption, additional information and documentation is available on the official SQLCipher site. Special thanks for Zetetic.

Requirements

Swift 5 and beyond.

Usage

import SQLCipher

func main() {
    var db: COpaquePointer = nil
    
    let key = "key"
    let sql = "CREATE TABLE test(id INTEGER, field1 TEXT, field2 TEXT)"

    sqlite3_open_v2("db.sqlite3", &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, nil)
    sqlite3_key(db, key, Int32(key.utf8.count))

    if sqlite3_exec(db, sql, nil, nil, nil) != SQLITE_OK {
        print("Error on execute")
    }
}

To encrypt a database programmatically you can use the sqlite3_key function. The data provided in pKey is converted to an encryption key according to the same rules as PRAGMA key.

int sqlite3_key(sqlite3 *db, const void *pKey, int nKey)

License

MIT

Releases

No releases published

Packages

No packages published

Languages