Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to generate oauth signature using HMAC-SHA1 in Symbian C++

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia E7 , Symbian Anna
Article
Keywords: CHMAC, Oauth
Created: shafali gupta (28 Jan 2010)
Reviewed: ashraf fawzy (06 Dec 2011)
Last edited: hamishwillee (23 Apr 2012)

This code snippet shows how to generate an OAUTH signature using HMAC-SHA1 in Symbian C++. The oauth_signature is a signature computed from the base URL and a secret key, so before generating signature you must know about the key and base URL.

Includes

#include <hash.h>
#include <IMCVCODC.H>

Library

Link against:
hash.lib
imut.lib

Source

CSHA1* sha=CSHA1::NewL();
TBuf8<100> keyVal;
keyVal.Copy(_L8("Place your key value here"));
CHMAC* hmac=CHMAC::NewL(keyVal,sha);
TBuf8<1024> baseString;
//example base string (GET&http%3A%2F%2Fabc.com%2Frequest_token&oauth_consumer_key%3Deffe)
baseString.Copy(_L8("Add your base string for which the signature need to be generated"));
TPtrC8 hashedSig(hmac->Hash(baseString));
TImCodecB64 b64enc;
b64enc.Initialise();
HBufC8* buf = HBufC8::NewL(hashedSig.Length() * 2);
buf->Des().Copy(hashedSig);
TBuf8<512> result;
// encode your signature into base64 or encoding scheme required
b64enc.Encode( buf->Des(),result);
 
if(hmac)
{
delete hmac;
hmac=NULL;
}
This page was last modified on 23 April 2012, at 23:53.
93 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×