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.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License v1.0.