jn7163 / sqlciphermanager Goto Github PK
View Code? Open in Web Editor NEWThis project forked from sqlcipher/sqlciphermanager
SQLCipher access manager class, and a Cocoa project for building a static library
Home Page: http://www.zetetic.net
This project forked from sqlcipher/sqlciphermanager
SQLCipher access manager class, and a Cocoa project for building a static library
Home Page: http://www.zetetic.net
== SQLCipher Manager == SQLCipher is an SQLite extension that provides transparent 256 bit AES encryption of database files. http://github.com/sjlombardo/sqlcipher SQLCipherManager is a class implementing a singleton object for accessing the database connection. Sounds fairly unnecessary until you consider that SQLCipher databases are protected by a key, the databases can be re-keyed, there are optional settings for key-derivation and AES cipher modes, and it's the kind of code you'd want to re-use in multiple programs. Questions about this code can be posted to the SQLCipher-Users Google Group: http://groups.google.com/group/sqlcipher Please use the Github Issues tracker to report bugs and make enhancement requests or, better yet, fork the code and send pull requests / patches. Discussion: We needed a singleton object/class for our iPhone application using SQLCipher, and this implements a delegate protocol they can use to respond to interesting events. An application might be wired create an application-specific schema once the database is created, or it might be configured to check the schema version after the database is opened and do a migration if it's out of date. Usage example from the application delegate of our iPhone application Strip: - (void)applicationDidFinishLaunching:(UIApplication *)application { NSLog(@"Setting up sqlcipher manager, and ourself as delegate..."); // setup the db manager register as the delegate SQLCipherManager *dm = [SQLCipherManager sharedManager]; [dm setDelegate:self]; // set the databasePath property (required), use default iphone app documents directory NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *saveDirectory = [paths objectAtIndex:0]; NSString *databasePath = [saveDirectory stringByAppendingPathComponent:CONFIG_DBNAME]; NSLog(@"setting db path to %@", databasePath); [dm setDatabasePath:databasePath]; [self launchLoginView]; } # pragma mark - # pragma mark SQLCipherManagerDelegate - (void)didOpenDatabase { NSLog(@"Database opened"); SQLCipherManager *dm = [SQLCipherManager sharedManager]; NSUInteger schemaVersion = [dm getSchemaVersion]; if (schemaVersion != CONFIG_SCHEMAVERSION) { NSLog(@"handing off to schema manager, found old version %d", schemaVersion); StripSchemaManager *schemaManager = [[StripSchemaManager alloc] initWithSQLCipherManager:dm]; [schemaManager migrate:CONFIG_SCHEMAVERSION]; [schemaManager release]; } } - (void)didCreateDatabase { NSLog(@"Database created, migrating"); SQLCipherManager *dm = [SQLCipherManager sharedManager]; StripSchemaManager *schemaManager = [[StripSchemaManager alloc] initWithSQLCipherManager:dm]; [schemaManager migrate:CONFIG_SCHEMAVERSION]; } - (void)didEncounterDatabaseError:(NSString *)error { NSLog(@"Database error! %@", error); SQLCipherManager *dm = [SQLCipherManager sharedManager]; [dm closeDatabase]; abort(); // ouch, yo, but it leaves us a crash log for later } - (void)didEncounterRekeyError { [self lockApplication]; [self presentError:[NSError errorUsingDatabase:@"An error occured rekeying the database. Please login again using your original password" reason:@""]]; } Use of this software is governed by an MIT-style license. [License] Copyright (c) 2010, ZETETIC LLC All rights reserved. http://www.zetetic.net 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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.