File: provider_notes_sqlcipher.html

package info (click to toggle)
libgda5 5.2.10-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 76,168 kB
  • sloc: ansic: 495,319; xml: 10,486; yacc: 5,165; sh: 4,451; makefile: 4,095; php: 1,416; java: 1,300; javascript: 1,298; python: 896; sql: 879; perl: 116
file content (105 lines) | stat: -rw-r--r-- 5,288 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>For SQLCipher: GNOME Data Access 5 manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="GNOME Data Access 5 manual">
<link rel="up" href="provider-notes.html" title="Provider's notes">
<link rel="prev" href="provider_notes_sqlite.html" title="For SQLite">
<link rel="next" href="provider_notes_ldap.html" title="For LDAP">
<meta name="generator" content="GTK-Doc V1.32 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="provider-notes.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="provider_notes_sqlite.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="provider_notes_ldap.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="provider_notes_sqlcipher"></a>For SQLCipher</h2></div></div></div>
<p>
    The SQLCipher database provider allows one to connect to a database encrypted using the
    <a class="ulink" href="http://www.zetetic.net/code/sqlcipher" target="_top">SQLCipher</a> adaptations to the SQLite
    database. This section deals about how to manage the passphrase associated with a database file, please
    also consult the information <a class="ulink" href="http://sqlcipher.net/sqlcipher-api/" target="_top">provided by SQLCipher</a>
    before attempting to use this database provider.
  </p>
<p>
    The first noticeable point is that any SQLite database file can be opened using the SQLCipher and
    will remain useable with the "standard" SQLite provider as long as it's not explicitely encrypted using
    a passphrase.
  </p>
<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.2.11.6.4"></a>How to create and encrypted database</h3></div></div></div>
<p>
      To create an encrypted database, you can use the <span class="application">gda-sql</span> and when prompted
      enter the requested passphrase, as:
      </p>
<pre class="programlisting">prompt&gt; gda-sql-5.0 "SQLCipher://DB_NAME=testcrypt"
Welcome to the GDA SQL console, version 5.1.0

Type: .copyright to show usage and distribution terms
      .? for help with internal commands
      .q (or CTRL-D) to quit
      (the '.' can be replaced by a '\')
      or any query terminated by a semicolon

Opening connection 'c0' for: SQLCipher://DB_NAME=testcrypt
	Password for 'c0':</pre>
<p>
    </p>
</div>
<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.2.11.6.5"></a>How to encrypt an existing plaintext database to an encrypted database file</h3></div></div></div>
<p>
      To encrypt an existing (SQLite) database, connect to the plaintext database using the SQLCipher provider and execute the
      following SQL commands (replace the passphrase with the requested passphrase):
      </p>
<pre class="programlisting">ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'passphrase';
SELECT sqlcipher_export('encrypted');
DETACH DATABASE encrypted; </pre>
<p>
      This step prevents opening the database file by the "standard" SQLite provider.
    </p>
</div>
<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.2.11.6.6"></a>How to change the passphrase of an encrypted database</h3></div></div></div>
<p>
      To change an encrypted database's passphrase, open a connection to the database and enter the following
      SQL command (replace the passphrase with the requested new passphrase):
      </p>
<pre class="programlisting">PRAGMA rekey = 'passphrase';</pre>
<p>
    </p>
</div>
<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.2.11.6.7"></a>How to decrypt an existing database to a plaintext database</h3></div></div></div>
<p>
      To decrypt an existing encrypted database, connect to the database using the SQLCipher provider and execute the
      following SQL commands (replace the passphrase with the requested passphrase):
      </p>
<pre class="programlisting">ATTACH DATABASE 'plaintext.db' AS plaintext KEY '';
SELECT sqlcipher_export('plaintext');
DETACH DATABASE plaintext; </pre>
<p>
      This step allows opening the database file by the "standard" SQLite provider.
    </p>
</div>
<p>
    Also refer to the <a class="link" href="provider_notes_sqlite.html" title="For SQLite">SQLite's provider's notes</a>,
    and <a class="link" href="limitations_sqlcipher.html" title="For SQLCipher">SQLCipher provider's limitations</a>.
  </p>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.32</div>
</body>
</html>