decryption using sqlcipher in iphone - iphone

Okey, so i am studying sqlcipher and preparing a document on it. so far study shows that how to encrypt database, i could not find how to decrypt database. Like that i have few more questions.
I found that you can not perform coredata operation on encrypted database.so
1) Can i run a sql query on encrypted database.
2) so if i have to perform a coredata operation, so i have to decrypt the database.
3) and last but not least, how to do decryption using sqlcipher.
Please answer if these questions make sense.
Thanks

Yes, you can perform a SQL query on an encrypted database, however the pages within a SQLCipher enabled SQLite database need to be decrypted prior to retrieving the unencrypted data. In order to access an SQLCipher encrypted database, you need issue either the PRAGMA key command, or programmatically call sqlite3_key. Additional documentation can be found here, along with the mailing list here.

Related

Implementing Full text search on encrypted data

In one of my use cases I need to provide the similar experience people have while they search their mailbox like Gmail. It can search through both email subject and body.
I have some support tickets saved in Postgres. These tickets contain user messages which we can't store in plain text. We have to encrypt the data. Now if we want to build an index for providing full text search how do we go about it considering the index can't contain the actual data
Any pointer on how Gmail or any other similar providers solve this problem would also be great.
There is no way to do that. Either data are encrypted or not. If they are encrypted, the database does not know the value, so it cannot perform full text search. That's pretty obvious.
Security comes at a price, and in this case, it is performance.
PostGreSQL is not able to encrypt data at the storage level as Oracle or Microsoft SQL Server do with Transparent Data Encryption (TDE). When Using TDE the data are encrypted in the storage files, not in memory so, you can use a fulltext search as usual.

Using sp_helptext on a encrypted store procedure

Yesterday I created a store procedure with encryption for an exercise purposes but I forgot to save the query.
Today I was planning to view the tsql code by using
exec sp_helptext 'procedure_name'
But since it is encrypted I can't see the code. I was wondering if there is a way to solve this?
Providing the article in the comment as an answer so that more folks may benefit
This article goes into a lot of details on how to decrypt such objects..
It talks about a basic approach using code to decrypt the code from the system tables as well as using 3rd party tools such as DAC and Optillect (which it seems does not need admin privileges)
NOTE: I am assuming you are using sql-server since you have tagged as tsql

Rails 4: encrypt/decrypt email and store in DB

Passwords are hashed with a salt and are thus "secure" (relatively speaking) by default using has_secure_password in Rails 4. But what I want to do is encrypt the email at rest in the DB so if the database is compromised somehow the emails aren't just in plaintext.
I've looked at just writing my own encrypt/decrypt functions, but that's dangerous. I've looked at attr_encrypted (and have used it before) but it's not really compatible with the new Model.find_by(key: value) syntax that Rails 4+ pushes, and I don't want to create a hacked fix.
Is there anything out there already that will allow me to easily encrypt an attribute in the DB at rest and then decrypt it when I need to find it? I can't use hashes because I need the decrypted value to display and send emails to later.
I've googled for a while but can't seem to find anything like this. Surely encrypt/decrypt is something very basic that's been put into a convenient gem that's been reviewed by the community?
Have you considered the attr_encrypted gem?

how to deal with encrypted sqlite database in iPhone?

I have an encrypted version of an sqlite database
and also I have the KEY
but honestly I have no idea about using it or how to get the data from the encrypted database?
I guess the solution somewhere in the open function?
if(sqlite3_open([_dbPath UTF8String],&database)==SQLITE_OK);
Can anybody help me??
The core SQLite database implementation does not itself provide encryption support. There does however exist a number of extensions for adding encryption to SQLite. Some of these encrypt the entire database file while some other only encrypt the contents of the tables.
These extensions are for the most part not compatible, so you will most likely have to use the same extension on the iPhone as the one used on C#. And if you're lucky that extension is also supported on iOS.

iPhone:Create Password Protect SQLite database

i am able to create sqlite database using firefox addon and use database in iPhone. Now I want to give the the password to database and used it in my iPhone application. i tried a lot on google to search the proper way yo create password protected database but still no success.
anybody have idea that how can create the password protected sqlite database and how can we use it in iPhone
Try SQLiteEncrypt.The SQLiteEncrypt is an AES encryption embedded SQLite database engine through which you can encrypt and decrypt your SQLite database file. When set a password key into your database file, content is no longer stored in cleartext, so that we achieve the purpose of data protection.
But it is not free.
Note: But IT is not for iOS (thanks brad to pointed it out).
*Edit***
For iPhone you can use SQLCIPHER which is an open source full database encryption for sqlite.
Unfortunately, there is no free solution for doing that.
There are some commercial applications, which allows sqlite database encryption.
Also, there is virtual filesystem support in SQLite, where you can change calls which reads/writes data to SQLite database, however that will require some coding.