Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / html / python / lib / module-hmac.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="module-md5.html" />
13<link rel="prev" href="crypto.html" />
14<link rel="parent" href="crypto.html" />
15<link rel="next" href="module-md5.html" />
16<meta name='aesop' content='information' />
17<title>15.1 hmac -- Keyed-Hashing for Message Authentication</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="15. Cryptographic Services"
25 href="crypto.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="15. Cryptographic Services"
28 href="crypto.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="15.2 md5 "
31 href="module-md5.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="crypto.html">15. Cryptographic Services</A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="crypto.html">15. Cryptographic Services</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="module-md5.html">15.2 md5 </A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION0017100000000000000000">
5615.1 <tt class="module">hmac</tt> --
57 Keyed-Hashing for Message Authentication</A>
58</H1>
59
60<P>
61<A NAME="module-hmac"></A>
62
63<P>
64
65<span class="versionnote">New in version 2.2.</span>
66
67<P>
68This module implements the HMAC algorithm as described by <a class="rfc" id='rfcref-92061' xml:id='rfcref-92061'
69href="http://www.faqs.org/rfcs/rfc2104.html">RFC 2104</a>.
70
71<P>
72<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
73 <td><nobr><b><tt id='l2h-4807' xml:id='l2h-4807' class="function">new</tt></b>(</nobr></td>
74 <td><var>key</var><big>[</big><var>, msg</var><big>[</big><var>, digestmod</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
75<dd>
76 Return a new hmac object. If <var>msg</var> is present, the method call
77 <code>update(<var>msg</var>)</code> is made. <var>digestmod</var> is the digest
78 module for the HMAC object to use. It defaults to the
79 <tt class="module"><a href="module-md5.html">md5</a></tt> module.
80</dl>
81
82<P>
83An HMAC object has the following methods:
84
85<P>
86<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
87 <td><nobr><b><tt id='l2h-4808' xml:id='l2h-4808' class="method">update</tt></b>(</nobr></td>
88 <td><var>msg</var>)</td></tr></table></dt>
89<dd>
90 Update the hmac object with the string <var>msg</var>. Repeated calls
91 are equivalent to a single call with the concatenation of all the
92 arguments: <code>m.update(a); m.update(b)</code> is equivalent to
93 <code>m.update(a + b)</code>.
94</dl>
95
96<P>
97<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
98 <td><nobr><b><tt id='l2h-4809' xml:id='l2h-4809' class="method">digest</tt></b>(</nobr></td>
99 <td><var></var>)</td></tr></table></dt>
100<dd>
101 Return the digest of the strings passed to the <tt class="method">update()</tt>
102 method so far. This is a 16-byte string (for <tt class="module"><a href="module-md5.html">md5</a></tt>) or a
103 20-byte string (for <tt class="module"><a href="module-sha.html">sha</a></tt>) which may contain non-ASCII
104 characters, including NUL bytes.
105</dl>
106
107<P>
108<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
109 <td><nobr><b><tt id='l2h-4810' xml:id='l2h-4810' class="method">hexdigest</tt></b>(</nobr></td>
110 <td><var></var>)</td></tr></table></dt>
111<dd>
112 Like <tt class="method">digest()</tt> except the digest is returned as a string of
113 length 32 for <tt class="module"><a href="module-md5.html">md5</a></tt> (40 for <tt class="module"><a href="module-sha.html">sha</a></tt>), containing
114 only hexadecimal digits. This may be used to exchange the value
115 safely in email or other non-binary environments.
116</dl>
117
118<P>
119<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
120 <td><nobr><b><tt id='l2h-4811' xml:id='l2h-4811' class="method">copy</tt></b>(</nobr></td>
121 <td><var></var>)</td></tr></table></dt>
122<dd>
123 Return a copy (``clone'') of the hmac object. This can be used to
124 efficiently compute the digests of strings that share a common
125 initial substring.
126</dl>
127
128<DIV CLASS="navigation">
129<div class='online-navigation'>
130<p></p><hr />
131<table align="center" width="100%" cellpadding="0" cellspacing="2">
132<tr>
133<td class='online-navigation'><a rel="prev" title="15. Cryptographic Services"
134 href="crypto.html"><img src='../icons/previous.png'
135 border='0' height='32' alt='Previous Page' width='32' /></A></td>
136<td class='online-navigation'><a rel="parent" title="15. Cryptographic Services"
137 href="crypto.html"><img src='../icons/up.png'
138 border='0' height='32' alt='Up One Level' width='32' /></A></td>
139<td class='online-navigation'><a rel="next" title="15.2 md5 "
140 href="module-md5.html"><img src='../icons/next.png'
141 border='0' height='32' alt='Next Page' width='32' /></A></td>
142<td align="center" width="100%">Python Library Reference</td>
143<td class='online-navigation'><a rel="contents" title="Table of Contents"
144 href="contents.html"><img src='../icons/contents.png'
145 border='0' height='32' alt='Contents' width='32' /></A></td>
146<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
147 border='0' height='32' alt='Module Index' width='32' /></a></td>
148<td class='online-navigation'><a rel="index" title="Index"
149 href="genindex.html"><img src='../icons/index.png'
150 border='0' height='32' alt='Index' width='32' /></A></td>
151</tr></table>
152<div class='online-navigation'>
153<b class="navlabel">Previous:</b>
154<a class="sectref" rel="prev" href="crypto.html">15. Cryptographic Services</A>
155<b class="navlabel">Up:</b>
156<a class="sectref" rel="parent" href="crypto.html">15. Cryptographic Services</A>
157<b class="navlabel">Next:</b>
158<a class="sectref" rel="next" href="module-md5.html">15.2 md5 </A>
159</div>
160</div>
161<hr />
162<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
163</DIV>
164<!--End of Navigation Panel-->
165<ADDRESS>
166See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
167</ADDRESS>
168</BODY>
169</HTML>