Skip to content

SQLiteCipher NSData key support #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SQLite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
DCC6B3801A9191C300734B78 /* SQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DCC6B3921A9191D100734B78 /* SQLiteCipher Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SQLiteCipher Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
DCC6B3961A91938F00734B78 /* sqlcipher.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = sqlcipher.xcodeproj; path = Vendor/sqlcipher/sqlcipher.xcodeproj; sourceTree = "<group>"; };
DCC6B3A31A9194A800734B78 /* Cipher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cipher.swift; sourceTree = "<group>"; };
DCC6B3A31A9194A800734B78 /* Cipher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cipher.swift; sourceTree = "<group>"; usesTabs = 0; };
DCC6B3A51A9194FB00734B78 /* CipherTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CipherTests.swift; sourceTree = "<group>"; };
DCF37F8119DDAC2D001534AA /* DatabaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTests.swift; sourceTree = "<group>"; };
DCF37F8419DDAF3F001534AA /* StatementTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = StatementTests.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
Expand Down
4 changes: 4 additions & 0 deletions SQLite/Value.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public struct Blob {
public init(bytes: UnsafePointer<Void>, length: Int) {
data = NSData(bytes: bytes, length: length)
}

public init (data: NSData) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we can get rid of this convenience initializer? The swift-2 branch actually uses a fully Swift implementation of Blob (no reliance on Foundation/NSData), which I may back-port, at which point you can still create a blob from NSData like this:

// data: NSData
let blob = Blob(bytes: data.bytes, length: data.length)

self.data = data
}

}

Expand Down
8 changes: 8 additions & 0 deletions SQLiteCipher/Cipher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,13 @@ extension Database {
public func rekey(key: String) {
try { sqlite3_rekey(self.handle, key, Int32(count(key.utf8))) }
}

public func key(key: Blob) {
try { sqlite3_key(self.handle, key.bytes, Int32(key.length)) }
}

public func rekey(key: Blob) {
try { sqlite3_rekey(self.handle, key.bytes, Int32(key.length)) }
}

}