📄 classalgorithm.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Algorithm class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center>
<hr><h1>Algorithm Class Reference</h1><code>#include <<a class="el" href="algorithm_8h-source.html">algorithm.h</a>></code>
<p>
<a href="classAlgorithm-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td colspan=2><br><h2>Public Types</h2></td></tr>
<tr><td nowrap align=right valign=top>enum </td><td valign=bottom><b>CODEC</b> { <b>BASE64</b>,
<b>BASE64_NIL</b>
}</td></tr>
<tr><td colspan=2><br><h2>Static Public Methods</h2></td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classAlgorithm.html#d0">encode</a> (const string &str, CODEC codec)</td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classAlgorithm.html#d1">decode</a> (const string &str, CODEC codec)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classAlgorithm.html#d2">hmac_md5</a> (const string &text, const string &key, unsigned char *digest)</td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classAlgorithm.html#d3">hmac_md5_str</a> (const string &str, const string &key)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classAlgorithm.html#d4">hmac_sha1</a> (const string &text, const string &key, unsigned char *digest)</td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classAlgorithm.html#d5">hmac_sha1_str</a> (const string &str, const string &key)</td></tr>
<tr><td colspan=2><br><h2>Static Protected Methods</h2></td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classAlgorithm.html#e0">enc_base64</a> (const string &orig_str, string *enc_str)</td></tr>
<tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classAlgorithm.html#e1">dec_base64</a> (const string &enc_str, string *orig_str)</td></tr>
<tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classAlgorithm.html#e2">dec_base64_nil</a> (const string &enc_str, string *orig_str)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classAlgorithm.html#e3">enc_base64_nil</a> (string orig_str, string *enc_str)</td></tr>
<tr><td colspan=2><br><h2>Static Protected Attributes</h2></td></tr>
<tr><td nowrap align=right valign=top>char </td><td valign=bottom><a class="el" href="classAlgorithm.html#q0">tbl_base64</a> [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
This class provides some convenient methods for the following algorithms: BASE64, BASE64_NIL, hmac_md5 and hmac_sha1.
<p>
<dl compact><dt><b>
Author: </b><dd>
Timo Benk <<a href="mailto:t_benk@web.de">t_benk@web.de</a>> </dl>
<p>
<hr><h2>Member Function Documentation</h2>
<a name="e1" doxytag="Algorithm::dec_base64"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> int Algorithm::dec_base64 </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const string & </td>
<td class="mdname" nowrap> <em>enc_str</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>string * </td>
<td class="mdname" nowrap> <em>orig_str</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [static, protected]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Decode enc_str with the base64 codec and store the result in the string pointed by orig_str. If successfull 0 is returned, and -1 if the base64 data was invalid.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>enc_str</em> </td><td>
The string that should be decoded. </td></tr>
<tr><td valign=top><em>orig_str</em> </td><td>
The resulting decoded string will be stored at the address pointed to by orig_str. </td></tr>
</table>
</dl><dl compact><dt><b>
Returns: </b><dd>
0 if the decoding process was successfull and -1 if the base64 data was invalid. </dl> </td>
</tr>
</table>
<a name="e2" doxytag="Algorithm::dec_base64_nil"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> int Algorithm::dec_base64_nil </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const string & </td>
<td class="mdname" nowrap> <em>enc_str</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>string * </td>
<td class="mdname" nowrap> <em>orig_str</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [static, protected]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Decode enc_str with a slightly advanced base64 codec and store the result in the string pointed by orig_str. Each zero byte will be substituted with the sequence "<NIL>". If successfull 0 is returned, and -1 if the base64 data was invalid.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>enc_str</em> </td><td>
The string that should be decoded. </td></tr>
<tr><td valign=top><em>orig_str</em> </td><td>
The resulting decoded string will be stored at the address pointed to by orig_str. </td></tr>
</table>
</dl><dl compact><dt><b>
Returns: </b><dd>
0 if the decodeing process was successfull and -1 if the base64 data was invalid. </dl> </td>
</tr>
</table>
<a name="d1" doxytag="Algorithm::decode"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> string Algorithm::decode </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const string & </td>
<td class="mdname" nowrap> <em>str</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>CODEC </td>
<td class="mdname" nowrap> <em>codec</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [static]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Decode str with the given codec.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>str</em> </td><td>
The string that should be decoded. </td></tr>
<tr><td valign=top><em>codec</em> </td><td>
The codec that should be used. </td></tr>
</table>
</dl><dl compact><dt><b>
Returns: </b><dd>
The encoded string.</dl><dl compact><dt><b>
Exceptions: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em><a class="el" href="classDecodeException.html">DecodeException</a></em> </td><td>
If the BASE64 data was invalid. </td></tr>
</table>
</dl> </td>
</tr>
</table>
<a name="e0" doxytag="Algorithm::enc_base64"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void Algorithm::enc_base64 </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const string & </td>
<td class="mdname" nowrap> <em>orig_str</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>string * </td>
<td class="mdname" nowrap> <em>enc_str</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [static, protected]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Encode orig_str with the base64 codec and store the result in the string pointed by enc_str.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>orig_str</em> </td><td>
The string that should be encoded. </td></tr>
<tr><td valign=top><em>enc_str</em> </td><td>
The resulting encoded string will be stored at the address pointed to by enc_str. </td></tr>
</table>
</dl> </td>
</tr>
</table>
<a name="e3" doxytag="Algorithm::enc_base64_nil"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void Algorithm::enc_base64_nil </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">string </td>
<td class="mdname" nowrap> <em>orig_str</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>string * </td>
<td class="mdname" nowrap> <em>enc_str</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [static, protected]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Encode enc_str with a slightly advanced base64 codec and store the result in the string pointed by orig_str. The sequence "<NIL>" will be substituted with one zero byte.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>orig_str</em> </td><td>
The string that should be encoded. </td></tr>
<tr><td valign=top><em>enc_str</em> </td><td>
The resulting encoded string will be stored at the address pointed to by enc_str. </td></tr>
</table>
</dl> </td>
</tr>
</table>
<a name="d0" doxytag="Algorithm::encode"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -