1<!--$Id: env_set_encrypt.so,v 10.23 2004/09/28 15:04:20 bostic Exp $-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB: DbEnv::set_encrypt</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<table width="100%"><tr valign=top>
12<td>
13<b>DbEnv::set_encrypt</b>
14</td>
15<td align=right>
16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a>
17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
18</tr></table>
19<hr size=1 noshade>
20<tt>
21<b><pre>
22#include &lt;db_cxx.h&gt;
23<p>
24int
25DbEnv::set_encrypt(const char *passwd, u_int32_t flags);
26<p>
27int
28DbEnv::get_encrypt_flags(u_int32_t *flagsp);
29</pre></b>
30<hr size=1 noshade>
31<b>Description: DbEnv::set_encrypt</b>
32<p>Set the password used by the Berkeley DB library to perform encryption and
33decryption.</p>
34<p>The DbEnv::set_encrypt method configures a database environment, not only operations
35performed using the specified <a href="../api_cxx/env_class.html">DbEnv</a> handle.</p>
36<p>The DbEnv::set_encrypt method may not be called after the <a href="../api_cxx/env_open.html">DbEnv::open</a> method is
37called.
38If the database environment already exists when
39<a href="../api_cxx/env_open.html">DbEnv::open</a> is called, the information specified to DbEnv::set_encrypt
40must be consistent with the existing environment or an error will be
41returned.
42</p>
43<p>The DbEnv::set_encrypt method
44either returns a non-zero error value
45or throws an exception that encapsulates a non-zero error value on
46failure, and returns 0 on success.
47</p>
48<b>Parameters</b> <br>
49 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or
50the following value:
51<br>
52<b><a name="DB_ENCRYPT_AES">DB_ENCRYPT_AES</a></b><ul compact><li>Use the Rijndael/AES (also known as the Advanced Encryption Standard
53and Federal Information Processing Standard (FIPS) 197) algorithm for
54encryption or decryption.</ul>
55<br></ul>
56 <b>passwd</b><ul compact><li>The <b>passwd</b> parameter is the password used to perform encryption
57and decryption.</ul>
58<br>
59<br><b>Errors</b>
60<p>The DbEnv::set_encrypt method
61may fail and throw
62<a href="../api_cxx/except_class.html">DbException</a>,
63encapsulating one of the following non-zero errors, or return one of
64the following non-zero errors:</p>
65<br>
66<b>EINVAL</b><ul compact><li>If the method was called after
67<a href="../api_cxx/env_open.html">DbEnv::open</a>
68was called; or if an
69invalid flag value or parameter was specified.</ul>
70<br>
71<br>
72<b>EOPNOTSUPP</b><ul compact><li>Cryptography is not available in this Berkeley DB release.</ul>
73<br>
74<hr size=1 noshade>
75<b>Description: DbEnv::get_encrypt_flags</b>
76<p>The DbEnv::get_encrypt_flags method returns the encryption flags.</p>
77<p>The DbEnv::get_encrypt_flags method may be called at any time during the life of the
78application.</p>
79<p>The DbEnv::get_encrypt_flags method
80either returns a non-zero error value
81or throws an exception that encapsulates a non-zero error value on
82failure, and returns 0 on success.
83</p>
84<b>Parameters</b> <br>
85 <b>flagsp</b><ul compact><li>The DbEnv::get_encrypt_flags method returns  the
86encryption flags in <b>flagsp</b>.</ul>
87<br>
88<hr size=1 noshade>
89<br><b>Class</b>
90<a href="../api_cxx/env_class.html">DbEnv</a>
91<br><b>See Also</b>
92<a href="../api_cxx/env_list.html">Database Environments and Related Methods</a>
93</tt>
94<table width="100%"><tr><td><br></td><td align=right>
95<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
96</td></tr></table>
97<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
98</body>
99</html>
100