×
Namespaces

Variants
Actions

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

From Nokia Developer 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 (24 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 24 April 2012, at 02:53.
109 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.

×