Skip to content

SQLiteCipher NSData key support #317

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

Merged
merged 2 commits into from
Jan 10, 2016
Merged

SQLiteCipher NSData key support #317

merged 2 commits into from
Jan 10, 2016

Conversation

agisboye
Copy link
Collaborator

Adds key and rekey methods that accept a key of type NSData.
This allows the database to be easily keyed with a key generated by
Security.framework:

let keyData = NSMutableData(length: 64)!
SecRandomCopyBytes(kSecRandomDefault, 64,
UnsafeMutablePointer<UInt8>(keyData.mutableBytes))
db.key(Blob(bytes: keyData.bytes, length: keyData.length))

// db2
let keyData = NSMutableData(length: 64)!
let _ = SecRandomCopyBytes(kSecRandomDefault, 64, UnsafeMutablePointer<UInt8>(keyData.mutableBytes))
try! db2.key("hello")
Copy link
Owner

Choose a reason for hiding this comment

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

Did you mean to key against keyData?

@stephencelis
Copy link
Owner

This is great! Found a small typo, but it's good to merge otherwise. @mikemee and I are in the process of extracting SQLiteCipher.swift into its own repo, so we'd like to get this in before #314 gets merged!

@agisboye
Copy link
Collaborator Author

I knew I'd missed something. Here we go. :-)

@stephencelis
Copy link
Owner

Thanks!

stephencelis added a commit that referenced this pull request Jan 10, 2016
SQLiteCipher NSData key support
@stephencelis stephencelis merged commit 4a0fa9c into stephencelis:master Jan 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants