diff -r 43e37759235e -r 51a74ef9ed63 Symbian3/SDK/Source/GUID-D88AA184-6E22-5069-A249-5AD83F548C56.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-D88AA184-6E22-5069-A249-5AD83F548C56.dita Wed Mar 31 11:11:55 2010 +0100 @@ -0,0 +1,24 @@ + + + + + +How to use the Hash API
How do I use the hash framework?

There are a couple of ways to interact with the hash framework. The following example is probably the most common:

+_LIT(messagePart1, "Hello "); +_LIT(messagePart2, "My "); +_LIT(messagePart3, "Name "); +_LIT(messagePart4, "is Fred"); +TBuf8<20> hash; + +CSHA1* sha1 = CSHA1::NewL(); +sha1->Update(messagePart1); +sha1->Update(messagePart2); +sha1->Update(messagePart3); +hash.Copy(sha1->Final(messagePart4)); +

Note that Final() has a version that takes no data parameter which may be useful in certain situations.

A few pointers:

  • You can reuse a hash object by calling Reset().

  • Both versions of Final() call Reset() at the end of their function automatically.

  • Be aware that the returned TPtrC8 from Final() points to an internal buffer. Calling Update() or Final() 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.

Which hash should I use?

Unless you have a specific need to support certain hashes, use SHA-1.

\ No newline at end of file