1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>DbEnv::set_encrypt()</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" /> 10 <link rel="up" href="env.html" title="Chapter 5. The DbEnv Handle" /> 11 <link rel="prev" href="envset_create_dir.html" title="DbEnv::set_create_dir()" /> 12 <link rel="next" href="envevent_notify.html" title="DbEnv::set_event_notify()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DbEnv::set_encrypt()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envset_create_dir.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 5. 23 The DbEnv Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="envevent_notify.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="envset_encrypt"></a>DbEnv::set_encrypt()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbEnv::set_encrypt(const char *passwd, u_int32_t flags); </pre> 42 <p> 43 Set the password used by the Berkeley DB library to perform encryption 44 and decryption. 45 </p> 46 <p> 47 The <code class="methodname">DbEnv::set_encrypt()</code> method configures a database environment, 48 not only operations performed using the specified 49 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle. 50 </p> 51 <p> 52 The <code class="methodname">DbEnv::set_encrypt()</code> method may not be called after the 53 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method is called. 54 If the database environment already exists when 55 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> is called, the 56 information specified to <code class="methodname">DbEnv::set_encrypt()</code> must be consistent 57 with the existing environment or an error will be returned. 58 </p> 59 <p> 60 The <code class="methodname">DbEnv::set_encrypt()</code> <span> 61 62 <span> 63 method either returns a non-zero error value or throws an 64 exception that encapsulates a non-zero error value on 65 failure, and returns 0 on success. 66 </span> 67 </span> 68 </p> 69 <div class="sect2" lang="en" xml:lang="en"> 70 <div class="titlepage"> 71 <div> 72 <div> 73 <h3 class="title"><a id="id1670004"></a>Parameters</h3> 74 </div> 75 </div> 76 </div> 77 <div class="sect3" lang="en" xml:lang="en"> 78 <div class="titlepage"> 79 <div> 80 <div> 81 <h4 class="title"><a id="id1669827"></a>flags</h4> 82 </div> 83 </div> 84 </div> 85 <p> 86 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 87 or the following value: 88 </p> 89 <div class="itemizedlist"> 90 <ul type="disc"> 91 <li> 92 <p><a id="set_encrypt_DB_ENCRYPT_AES"></a> 93 <code class="literal">DB_ENCRYPT_AES</code> 94 </p> 95 <p> 96 Use the Rijndael/AES (also known as the Advanced Encryption Standard 97 and Federal Information Processing Standard (FIPS) 197) algorithm for 98 encryption or decryption. 99 </p> 100 </li> 101 </ul> 102 </div> 103 </div> 104 <div class="sect3" lang="en" xml:lang="en"> 105 <div class="titlepage"> 106 <div> 107 <div> 108 <h4 class="title"><a id="id1670212"></a>passwd</h4> 109 </div> 110 </div> 111 </div> 112 <p> 113 The <span class="bold"><strong>passwd</strong></span> parameter is the password 114 used to perform encryption and decryption. 115 </p> 116 </div> 117 </div> 118 <div class="sect2" lang="en" xml:lang="en"> 119 <div class="titlepage"> 120 <div> 121 <div> 122 <h3 class="title"><a id="id1670197"></a>Errors</h3> 123 </div> 124 </div> 125 </div> 126 <p> 127 The <code class="methodname">DbEnv::set_encrypt()</code> <span> 128 129 <span> 130 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 131 exception, encapsulating one of the following non-zero errors, or return one 132 of the following non-zero errors: 133 </span> 134 </span> 135 </p> 136 <div class="sect3" lang="en" xml:lang="en"> 137 <div class="titlepage"> 138 <div> 139 <div> 140 <h4 class="title"><a id="id1670345"></a>EINVAL</h4> 141 </div> 142 </div> 143 </div> 144 <p> 145 If the method was called after <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> 146 was called; or if an invalid flag value or parameter was specified. 147 </p> 148 </div> 149 <div class="sect3" lang="en" xml:lang="en"> 150 <div class="titlepage"> 151 <div> 152 <div> 153 <h4 class="title"><a id="id1670079"></a>EOPNOTSUPP</h4> 154 </div> 155 </div> 156 </div> 157 <p> 158 Cryptography is not available in this Berkeley DB release. 159 </p> 160 </div> 161 </div> 162 <div class="sect2" lang="en" xml:lang="en"> 163 <div class="titlepage"> 164 <div> 165 <div> 166 <h3 class="title"><a id="id1670346"></a>Class</h3> 167 </div> 168 </div> 169 </div> 170 <p> 171 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> 172 </p> 173 </div> 174 <div class="sect2" lang="en" xml:lang="en"> 175 <div class="titlepage"> 176 <div> 177 <div> 178 <h3 class="title"><a id="id1670034"></a>See Also</h3> 179 </div> 180 </div> 181 </div> 182 <p> 183 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 184 </p> 185 </div> 186 </div> 187 <div class="navfooter"> 188 <hr /> 189 <table width="100%" summary="Navigation footer"> 190 <tr> 191 <td width="40%" align="left"><a accesskey="p" href="envset_create_dir.html">Prev</a> </td> 192 <td width="20%" align="center"> 193 <a accesskey="u" href="env.html">Up</a> 194 </td> 195 <td width="40%" align="right"> <a accesskey="n" href="envevent_notify.html">Next</a></td> 196 </tr> 197 <tr> 198 <td width="40%" align="left" valign="top">DbEnv::set_create_dir() </td> 199 <td width="20%" align="center"> 200 <a accesskey="h" href="index.html">Home</a> 201 </td> 202 <td width="40%" align="right" valign="top"> DbEnv::set_event_notify()</td> 203 </tr> 204 </table> 205 </div> 206 </body> 207</html> 208