Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 502

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qmessageauthenticationcode.cpp -->
  <title>QMessageAuthenticationCode Class | Qt Core 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QMessageAuthenticationCode</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QMessageAuthenticationCode Class</h1>
<!-- $$$QMessageAuthenticationCode-brief -->
<p>The <a href="qmessageauthenticationcode.html">QMessageAuthenticationCode</a> class provides a way to generate hash-based message authentication codes. <a href="#details">More...</a></p>
<!-- @@@QMessageAuthenticationCode -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QMessageAuthenticationCode&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 5.1</td></tr></table></div><ul>
<li><a href="qmessageauthenticationcode-members.html">List of all members, including inherited members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are reentrant.</p>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmessageauthenticationcode.html#QMessageAuthenticationCode">QMessageAuthenticationCode</a></b>(QCryptographicHash::Algorithm <i>method</i>, const QByteArray &amp;<i>key</i> = QByteArray())</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmessageauthenticationcode.html#dtor.QMessageAuthenticationCode">~QMessageAuthenticationCode</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessageauthenticationcode.html#addData">addData</a></b>(const char *<i>data</i>, int <i>length</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessageauthenticationcode.html#addData-1">addData</a></b>(const QByteArray &amp;<i>data</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmessageauthenticationcode.html#addData-2">addData</a></b>(QIODevice *<i>device</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessageauthenticationcode.html#reset">reset</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qmessageauthenticationcode.html#result">result</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessageauthenticationcode.html#setKey">setKey</a></b>(const QByteArray &amp;<i>key</i>)</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qmessageauthenticationcode.html#hash">hash</a></b>(const QByteArray &amp;<i>message</i>, const QByteArray &amp;<i>key</i>, QCryptographicHash::Algorithm <i>method</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QMessageAuthenticationCode-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qmessageauthenticationcode.html">QMessageAuthenticationCode</a> class provides a way to generate hash-based message authentication codes.</p>
<p><a href="qmessageauthenticationcode.html">QMessageAuthenticationCode</a> supports all cryptographic hashes which are supported by <a href="qcryptographichash.html">QCryptographicHash</a>.</p>
<p>To generate message authentication code, pass hash algorithm <a href="qcryptographichash.html#Algorithm-enum">QCryptographicHash::Algorithm</a> to constructor, then set key and message by <a href="qmessageauthenticationcode.html#setKey">setKey</a>() and <a href="qmessageauthenticationcode.html#addData">addData</a>() functions. Result can be acquired by <a href="qmessageauthenticationcode.html#result">result</a>() function.</p>
<pre class="cpp">

      <span class="type"><a href="qbytearray.html">QByteArray</a></span> key <span class="operator">=</span> <span class="string">&quot;key&quot;</span>;
      <span class="type"><a href="qbytearray.html">QByteArray</a></span> message <span class="operator">=</span> <span class="string">&quot;The quick brown fox jumps over the lazy dog&quot;</span>;
      ...
      <span class="type"><a href="qmessageauthenticationcode.html#QMessageAuthenticationCode">QMessageAuthenticationCode</a></span> code(<span class="type"><a href="qcryptographichash.html">QCryptographicHash</a></span><span class="operator">::</span>Sha1);
      code<span class="operator">.</span>setKey(key);
      code<span class="operator">.</span>addData(message);
      code<span class="operator">.</span>result()<span class="operator">.</span>toHex();      <span class="comment">// returns &quot;de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9&quot;</span>

</pre>
<p>Alternatively, this effect can be achieved by providing message, key and method to <a href="qmessageauthenticationcode.html#hash">hash</a>() method.</p>
<pre class="cpp">

      <span class="type"><a href="qmessageauthenticationcode.html#QMessageAuthenticationCode">QMessageAuthenticationCode</a></span><span class="operator">::</span>hash(message<span class="operator">,</span> key<span class="operator">,</span> <span class="type"><a href="qcryptographichash.html">QCryptographicHash</a></span><span class="operator">::</span>Sha1)<span class="operator">.</span>toHex();

</pre>
</div>
<p><b>See also </b><a href="qcryptographichash.html">QCryptographicHash</a>.</p>
<!-- @@@QMessageAuthenticationCode -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QMessageAuthenticationCode[overload1]$$$QMessageAuthenticationCodeQCryptographicHash::AlgorithmconstQByteArray& -->
<h3 class="fn" id="QMessageAuthenticationCode"><a name="QMessageAuthenticationCode"></a>QMessageAuthenticationCode::<span class="name">QMessageAuthenticationCode</span>(<span class="type"><a href="qcryptographichash.html#Algorithm-enum">QCryptographicHash::Algorithm</a></span> <i>method</i>, const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>key</i> = QByteArray())</h3>
<p>Constructs an object that can be used to create a cryptographic hash from data using method <i>method</i> and key <i>key</i>.</p>
<!-- @@@QMessageAuthenticationCode -->
<!-- $$$~QMessageAuthenticationCode[overload1]$$$~QMessageAuthenticationCode -->
<h3 class="fn" id="dtor.QMessageAuthenticationCode"><a name="dtor.QMessageAuthenticationCode"></a>QMessageAuthenticationCode::<span class="name">~QMessageAuthenticationCode</span>()</h3>
<p>Destroys the object.</p>
<!-- @@@~QMessageAuthenticationCode -->
<!-- $$$addData[overload1]$$$addDataconstchar*int -->
<h3 class="fn" id="addData"><a name="addData"></a><span class="type">void</span> QMessageAuthenticationCode::<span class="name">addData</span>(const <span class="type">char</span> *<i>data</i>, <span class="type">int</span> <i>length</i>)</h3>
<p>Adds the first <i>length</i> chars of <i>data</i> to the message.</p>
<!-- @@@addData -->
<!-- $$$addData$$$addDataconstQByteArray& -->
<h3 class="fn" id="addData-1"><a name="addData-1"></a><span class="type">void</span> QMessageAuthenticationCode::<span class="name">addData</span>(const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>data</i>)</h3>
<p>This function overloads <a href="qmessageauthenticationcode.html#addData">addData</a>().</p>
<!-- @@@addData -->
<!-- $$$addData$$$addDataQIODevice* -->
<h3 class="fn" id="addData-2"><a name="addData-2"></a><span class="type">bool</span> QMessageAuthenticationCode::<span class="name">addData</span>(<span class="type"><a href="qiodevice.html">QIODevice</a></span> *<i>device</i>)</h3>
<p>Reads the data from the open <a href="qiodevice.html">QIODevice</a> <i>device</i> until it ends and adds it to message. Returns <code>true</code> if reading was successful.</p>
<p><b>Note: </b><i>device</i> must be already opened.</p><!-- @@@addData -->
<!-- $$$hash[overload1]$$$hashconstQByteArray&constQByteArray&QCryptographicHash::Algorithm -->
<h3 class="fn" id="hash"><a name="hash"></a><code>[static] </code><span class="type"><a href="qbytearray.html">QByteArray</a></span> QMessageAuthenticationCode::<span class="name">hash</span>(const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>message</i>, const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>key</i>, <span class="type"><a href="qcryptographichash.html#Algorithm-enum">QCryptographicHash::Algorithm</a></span> <i>method</i>)</h3>
<p>Returns the authentication code for the message <i>message</i> using the key <i>key</i> and the method <i>method</i>.</p>
<!-- @@@hash -->
<!-- $$$reset[overload1]$$$reset -->
<h3 class="fn" id="reset"><a name="reset"></a><span class="type">void</span> QMessageAuthenticationCode::<span class="name">reset</span>()</h3>
<p>Resets message data. Calling this method doesn't affect the key.</p>
<!-- @@@reset -->
<!-- $$$result[overload1]$$$result -->
<h3 class="fn" id="result"><a name="result"></a><span class="type"><a href="qbytearray.html">QByteArray</a></span> QMessageAuthenticationCode::<span class="name">result</span>() const</h3>
<p>Returns the final authentication code.</p>
<p><b>See also </b><a href="qbytearray.html#toHex">QByteArray::toHex</a>().</p>
<!-- @@@result -->
<!-- $$$setKey[overload1]$$$setKeyconstQByteArray& -->
<h3 class="fn" id="setKey"><a name="setKey"></a><span class="type">void</span> QMessageAuthenticationCode::<span class="name">setKey</span>(const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>key</i>)</h3>
<p>Sets secret <i>key</i>. Calling this method automatically resets the object state.</p>
<!-- @@@setKey -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>