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.h> 39 40int 41DB->set_encrypt(DB *db, 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 <span> 58 method returns a non-zero error value on failure and 0 on success. 59 </span> 60 61 </span> 62 </p> 63 <div class="sect2" lang="en" xml:lang="en"> 64 <div class="titlepage"> 65 <div> 66 <div> 67 <h3 class="title"><a id="id1644985"></a>Parameters</h3> 68 </div> 69 </div> 70 </div> 71 <div class="sect3" lang="en" xml:lang="en"> 72 <div class="titlepage"> 73 <div> 74 <div> 75 <h4 class="title"><a id="id1644941"></a>flags</h4> 76 </div> 77 </div> 78 </div> 79 <p> 80 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 81 or the following value: 82 </p> 83 <div class="itemizedlist"> 84 <ul type="disc"> 85 <li> 86 <p><a id="set_encrypt_DB_ENCRYPT_AES"></a> 87 <code class="literal">DB_ENCRYPT_AES</code> 88 </p> 89 <p> 90 Use the Rijndael/AES (also known as the Advanced Encryption Standard 91 and Federal Information Processing Standard (FIPS) 197) algorithm for 92 encryption or decryption. 93 </p> 94 </li> 95 </ul> 96 </div> 97 </div> 98 <div class="sect3" lang="en" xml:lang="en"> 99 <div class="titlepage"> 100 <div> 101 <div> 102 <h4 class="title"><a id="id1645345"></a>passwd</h4> 103 </div> 104 </div> 105 </div> 106 <p> 107 The <span class="bold"><strong>passwd</strong></span> parameter is the password 108 used to perform encryption and decryption. 109 </p> 110 </div> 111 </div> 112 <div class="sect2" lang="en" xml:lang="en"> 113 <div class="titlepage"> 114 <div> 115 <div> 116 <h3 class="title"><a id="id1645336"></a>Errors</h3> 117 </div> 118 </div> 119 </div> 120 <p> 121 The <code class="methodname">DB->set_encrypt()</code> <span> 122 <span> 123 method may fail and return one of the following non-zero errors: 124 </span> 125 126 </span> 127 </p> 128 <div class="sect3" lang="en" xml:lang="en"> 129 <div class="titlepage"> 130 <div> 131 <div> 132 <h4 class="title"><a id="id1645042"></a>EINVAL</h4> 133 </div> 134 </div> 135 </div> 136 <p> 137 If the method was called after <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> 138 was called; or if an invalid flag value or parameter was specified. 139 </p> 140 </div> 141 <div class="sect3" lang="en" xml:lang="en"> 142 <div class="titlepage"> 143 <div> 144 <div> 145 <h4 class="title"><a id="id1645043"></a>EOPNOTSUPP</h4> 146 </div> 147 </div> 148 </div> 149 <p> 150 Cryptography is not available in this Berkeley DB release. 151 </p> 152 </div> 153 </div> 154 <div class="sect2" lang="en" xml:lang="en"> 155 <div class="titlepage"> 156 <div> 157 <div> 158 <h3 class="title"><a id="id1644947"></a>Class</h3> 159 </div> 160 </div> 161 </div> 162 <p> 163 <a class="link" href="db.html" title="Chapter��2.�� The DB Handle">DB</a> 164 </p> 165 </div> 166 <div class="sect2" lang="en" xml:lang="en"> 167 <div class="titlepage"> 168 <div> 169 <div> 170 <h3 class="title"><a id="id1645179"></a>See Also</h3> 171 </div> 172 </div> 173 </div> 174 <p> 175 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 176 </p> 177 </div> 178 </div> 179 <div class="navfooter"> 180 <hr /> 181 <table width="100%" summary="Navigation footer"> 182 <tr> 183 <td width="40%" align="left"><a accesskey="p" href="dbset_dup_compare.html">Prev</a>��</td> 184 <td width="20%" align="center"> 185 <a accesskey="u" href="db.html">Up</a> 186 </td> 187 <td width="40%" align="right">��<a accesskey="n" href="dbset_errcall.html">Next</a></td> 188 </tr> 189 <tr> 190 <td width="40%" align="left" valign="top">DB->set_dup_compare()��</td> 191 <td width="20%" align="center"> 192 <a accesskey="h" href="index.html">Home</a> 193 </td> 194 <td width="40%" align="right" valign="top">��DB->set_errcall()</td> 195 </tr> 196 </table> 197 </div> 198 </body> 199</html> 200