Skip to content

Commit 932d580

Browse files
committed
Fix SQLCipher subspec
1 parent 0ce78d9 commit 932d580

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Sources/SQLite/Core/Blob.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public final class Blob {
2727

2828
public let data: NSData
2929

30-
public var bytes: UnsafeRawPointer {
31-
data.bytes
30+
public var bytes: UnsafePointer<UInt8> {
31+
data.bytes.assumingMemoryBound(to: UInt8.self)
3232
}
3333

3434
public var length: Int {
@@ -64,7 +64,6 @@ public final class Blob {
6464

6565
public func toHex() -> String {
6666
guard length > 0 else { return "" }
67-
let bytes = bytes.assumingMemoryBound(to: UInt8.self)
6867

6968
var hex = ""
7069
for idx in 0..<length {

Sources/SQLite/Extensions/Cipher.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extension Connection {
3232
}
3333

3434
public func key(_ key: Blob, db: String = "main") throws {
35-
try _key_v2(db: db, keyPointer: key.bytes, keySize: key.bytes.count)
35+
try _key_v2(db: db, keyPointer: key.bytes, keySize: key.length)
3636
}
3737

3838
/// Same as `key(_ key: String, db: String = "main")`, running "PRAGMA cipher_migrate;"
@@ -53,7 +53,7 @@ extension Connection {
5353

5454
/// Same as `[`keyAndMigrate(_ key: String, db: String = "main")` accepting byte array as key
5555
public func keyAndMigrate(_ key: Blob, db: String = "main") throws {
56-
try _key_v2(db: db, keyPointer: key.bytes, keySize: key.bytes.count, migrate: true)
56+
try _key_v2(db: db, keyPointer: key.bytes, keySize: key.length, migrate: true)
5757
}
5858

5959
/// Change the key on an open database. NB: only works if the database is already encrypted.
@@ -68,7 +68,7 @@ extension Connection {
6868
}
6969

7070
public func rekey(_ key: Blob, db: String = "main") throws {
71-
try _rekey_v2(db: db, keyPointer: key.bytes, keySize: key.bytes.count)
71+
try _rekey_v2(db: db, keyPointer: key.bytes, keySize: key.length)
7272
}
7373

7474
/// Converts a non-encrypted database to an encrypted one.

Tests/SQLiteTests/Core/BlobTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ class BlobTests: XCTestCase {
3434
XCTAssertEqual(blob1, blob2)
3535
XCTAssertNotEqual(blob1, blob3)
3636
}
37+
38+
func XXX_test_init_with_mutable_data_fails() {
39+
_ = Blob(data: NSMutableData())
40+
}
3741
}

0 commit comments

Comments
 (0)