author | Dominic Pinkman <dominic.pinkman@nokia.com> |
Fri, 13 Aug 2010 16:47:46 +0100 | |
changeset 14 | 578be2adaf3e |
parent 5 | f345bda72bc4 |
permissions | -rw-r--r-- |
14
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
1 |
<?xml version="1.0" encoding="utf-8"?> |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
2 |
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
3 |
<!-- This component and the accompanying materials are made available under the terms of the License |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
4 |
"Eclipse Public License v1.0" which accompanies this distribution, |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
5 |
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
6 |
<!-- Initial Contributors: |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
7 |
Nokia Corporation - initial contribution. |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
8 |
Contributors: |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
9 |
--> |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
10 |
<!DOCTYPE concept |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
11 |
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
12 |
<concept xml:lang="en" id="GUID-D88AA184-6E22-5069-A249-5AD83F548C56"><title>How to use the Hash API</title><prolog><metadata><keywords/></metadata></prolog><conbody><ul><li id="GUID-019D2F91-38B5-5D35-B16F-F64E20188E8B"><p><xref href="GUID-D88AA184-6E22-5069-A249-5AD83F548C56.dita#GUID-D88AA184-6E22-5069-A249-5AD83F548C56/GUID-DEE9EA04-A6FD-5BE2-A26F-55126414FAC3">How do I use the hash framework?</xref> </p> </li> <li id="GUID-6BDA9DDE-F26C-5E49-91D5-6F1CA81656E3"><p><xref href="GUID-D88AA184-6E22-5069-A249-5AD83F548C56.dita#GUID-D88AA184-6E22-5069-A249-5AD83F548C56/GUID-AF3925CF-E372-56A4-A473-FF583F92AD08">Which hash should I use?</xref> </p> </li> </ul> <section id="GUID-DEE9EA04-A6FD-5BE2-A26F-55126414FAC3"><title>How do I use the hash framework?</title> <p>There are a couple of ways to interact with the hash framework. The following example is probably the most common: </p> <codeblock id="GUID-CECDA431-7E5D-530C-A6DE-273F8A33B530" xml:space="preserve"> |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
13 |
_LIT(messagePart1, "Hello "); |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
14 |
_LIT(messagePart2, "My "); |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
15 |
_LIT(messagePart3, "Name "); |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
16 |
_LIT(messagePart4, "is Fred"); |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
17 |
TBuf8<20> hash; |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
18 |
|
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
19 |
CSHA1* sha1 = CSHA1::NewL(); |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
20 |
sha1->Update(messagePart1); |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
21 |
sha1->Update(messagePart2); |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
22 |
sha1->Update(messagePart3); |
578be2adaf3e
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents:
5
diff
changeset
|
23 |
hash.Copy(sha1->Final(messagePart4)); |
1
25a17d01db0c
Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff
changeset
|
24 |
</codeblock> <p>Note that <codeph>Final()</codeph> has a version that takes no data parameter which may be useful in certain situations. </p> <p>A few pointers: </p> <ul><li id="GUID-A9716705-015A-5AFD-A038-BAB3F8D4C4DA"><p>You can reuse a hash object by calling <codeph>Reset()</codeph>. </p> </li> <li id="GUID-90C1BB63-563B-52D7-9B27-E3D638E00BA7"><p>Both versions of <codeph>Final()</codeph> call <codeph>Reset()</codeph> at the end of their function automatically. </p> </li> <li id="GUID-72D8B74B-CCAD-513B-951E-E06101644EA3"><p>Be aware that the returned <codeph>TPtrC8</codeph> from <codeph>Final()</codeph> points to an internal buffer. Calling <codeph>Update()</codeph> or <codeph>Final()</codeph> again changes the contents of this buffer and will destroy your previously computed hash. As in the example above, make sure you copy the data out if you need it. </p> </li> </ul> </section> <section id="GUID-AF3925CF-E372-56A4-A473-FF583F92AD08"><title>Which hash should I use?</title> <p>Unless you have a specific need to support certain hashes, use SHA-1. </p> </section> </conbody></concept> |