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>Db::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="db.html" title="Chapter 2. The Db Handle" /> 11 <link rel="prev" href="dbset_dup_compare.html" title="Db::set_dup_compare()" /> 12 <link rel="next" href="dbset_errcall.html" title="Db::set_errcall()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">Db::set_encrypt()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="dbset_dup_compare.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 2. 23 The Db Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="dbset_errcall.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="dbset_encrypt"></a>Db::set_encrypt()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41Db::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 Because databases opened within Berkeley DB environments use the 48 password specified to the environment, it is an error to attempt to 49 set a password in a database created within an environment. 50 </p> 51 <p> 52 The <code class="methodname">Db::set_encrypt()</code> method may not be called after the 53 <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> method is called. 54 </p> 55 <p> 56 The <code class="methodname">Db::set_encrypt()</code> <span> 57 58 <span> 59 method either returns a non-zero error value or throws an 60 exception that encapsulates a non-zero error value on 61 failure, and returns 0 on success. 62 </span> 63 </span> 64 </p> 65 <div class="sect2" lang="en" xml:lang="en"> 66 <div class="titlepage"> 67 <div> 68 <div> 69 <h3 class="title"><a id="id1645650"></a>Parameters</h3> 70 </div> 71 </div> 72 </div> 73 <div class="sect3" lang="en" xml:lang="en"> 74 <div class="titlepage"> 75 <div> 76 <div> 77 <h4 class="title"><a id="id1645302"></a>flags</h4> 78 </div> 79 </div> 80 </div> 81 <p> 82 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 83 or the following value: 84 </p> 85 <div class="itemizedlist"> 86 <ul type="disc"> 87 <li> 88 <p><a id="set_encrypt_DB_ENCRYPT_AES"></a> 89 <code class="literal">DB_ENCRYPT_AES</code> 90 </p> 91 <p> 92 Use the Rijndael/AES (also known as the Advanced Encryption Standard 93 and Federal Information Processing Standard (FIPS) 197) algorithm for 94 encryption or decryption. 95 </p> 96 </li> 97 </ul> 98 </div> 99 </div> 100 <div class="sect3" lang="en" xml:lang="en"> 101 <div class="titlepage"> 102 <div> 103 <div> 104 <h4 class="title"><a id="id1645731"></a>passwd</h4> 105 </div> 106 </div> 107 </div> 108 <p> 109 The <span class="bold"><strong>passwd</strong></span> parameter is the password 110 used to perform encryption and decryption. 111 </p> 112 </div> 113 </div> 114 <div class="sect2" lang="en" xml:lang="en"> 115 <div class="titlepage"> 116 <div> 117 <div> 118 <h3 class="title"><a id="id1645555"></a>Errors</h3> 119 </div> 120 </div> 121 </div> 122 <p> 123 The <code class="methodname">Db::set_encrypt()</code> <span> 124 125 <span> 126 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 127 exception, encapsulating one of the following non-zero errors, or return one 128 of the following non-zero errors: 129 </span> 130 </span> 131 </p> 132 <div class="sect3" lang="en" xml:lang="en"> 133 <div class="titlepage"> 134 <div> 135 <div> 136 <h4 class="title"><a id="id1645464"></a>EINVAL</h4> 137 </div> 138 </div> 139 </div> 140 <p> 141 If the method was called after <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> 142 was called; or if an invalid flag value or parameter was specified. 143 </p> 144 </div> 145 <div class="sect3" lang="en" xml:lang="en"> 146 <div class="titlepage"> 147 <div> 148 <div> 149 <h4 class="title"><a id="id1645465"></a>EOPNOTSUPP</h4> 150 </div> 151 </div> 152 </div> 153 <p> 154 Cryptography is not available in this Berkeley DB release. 155 </p> 156 </div> 157 </div> 158 <div class="sect2" lang="en" xml:lang="en"> 159 <div class="titlepage"> 160 <div> 161 <div> 162 <h3 class="title"><a id="id1645308"></a>Class</h3> 163 </div> 164 </div> 165 </div> 166 <p> 167 <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> 168 </p> 169 </div> 170 <div class="sect2" lang="en" xml:lang="en"> 171 <div class="titlepage"> 172 <div> 173 <div> 174 <h3 class="title"><a id="id1645672"></a>See Also</h3> 175 </div> 176 </div> 177 </div> 178 <p> 179 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 180 </p> 181 </div> 182 </div> 183 <div class="navfooter"> 184 <hr /> 185 <table width="100%" summary="Navigation footer"> 186 <tr> 187 <td width="40%" align="left"><a accesskey="p" href="dbset_dup_compare.html">Prev</a> </td> 188 <td width="20%" align="center"> 189 <a accesskey="u" href="db.html">Up</a> 190 </td> 191 <td width="40%" align="right"> <a accesskey="n" href="dbset_errcall.html">Next</a></td> 192 </tr> 193 <tr> 194 <td width="40%" align="left" valign="top">Db::set_dup_compare() </td> 195 <td width="20%" align="center"> 196 <a accesskey="h" href="index.html">Home</a> 197 </td> 198 <td width="40%" align="right" valign="top"> Db::set_errcall()</td> 199 </tr> 200 </table> 201 </div> 202 </body> 203</html> 204