<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Examples</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="crack.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.crack.html">Crack Functions</a></div> <div class="up"><a href="book.crack.html">Crack</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="crack.examples" class="appendix"> <h1>Examples</h1> <p class="para"> This example shows how to open a CrackLib dictionary, test a given password, retrieve any diagnostic messages, and close the dictionary. <div class="example" id="example-827"> <p><strong>Example #1 CrackLib example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Open CrackLib Dictionary<br /></span><span style="color: #0000BB">$dictionary </span><span style="color: #007700">= </span><span style="color: #0000BB">crack_opendict</span><span style="color: #007700">(</span><span style="color: #DD0000">'/usr/local/lib/pw_dict'</span><span style="color: #007700">)<br /> or die(</span><span style="color: #DD0000">'Unable to open CrackLib dictionary'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Perform password check<br /></span><span style="color: #0000BB">$check </span><span style="color: #007700">= </span><span style="color: #0000BB">crack_check</span><span style="color: #007700">(</span><span style="color: #0000BB">$dictionary</span><span style="color: #007700">, </span><span style="color: #DD0000">'gx9A2s0x'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Retrieve messages<br /></span><span style="color: #0000BB">$diag </span><span style="color: #007700">= </span><span style="color: #0000BB">crack_getlastmessage</span><span style="color: #007700">();<br />echo </span><span style="color: #0000BB">$diag</span><span style="color: #007700">; </span><span style="color: #FF8000">// 'strong password'<br /><br />// Close dictionary<br /></span><span style="color: #0000BB">crack_closedict</span><span style="color: #007700">(</span><span style="color: #0000BB">$dictionary</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> If <span class="function"><a href="function.crack-check.html" class="function">crack_check()</a></span> returns <strong><code>TRUE</code></strong>, <span class="function"><a href="function.crack-getlastmessage.html" class="function">crack_getlastmessage()</a></span> will return <em>'strong password'</em>. </p> </p></blockquote> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="crack.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.crack.html">Crack Functions</a></div> <div class="up"><a href="book.crack.html">Crack</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>