Community: Wiki

你在这里: You Are Here: Olet tässä: Vous êtes ici: Sie befinden sich hier: Tu sei qui: 現在のページ: Você está aqui: Вы здесь: Usted está aquí:
This page was last modified 14:54, 24 June 2008.

Password based encryption

From Forum Nokia Wiki

This sample shows how to use the password based encryption API's.

These were recently released here.

_LIT8(KSourceData, "Data to be encrypted");
const TPBPassword KEncryptionKey(_L8("password"));
			
CPBEncryptElement* data = CPBEncryptElement::NewLC(KEncryptionKey);
CPBEncryptor* encrypter = data->NewEncryptLC();
HBufC8* ciphertext = HBufC8::NewLC( encrypter->MaxFinalOutputLength(
                                                 KSourceData().Length()));
TPtr8 ciphertextPtr = ciphertext->Des();        
encrypter->ProcessFinalL(KSourceData, ciphertextPtr);
// ciphertext now contains the encrypted data

Note that when saving this you MUST stream out the CPBEncryptionData with the cipher text as this has the salt and cipher.

Likewise restoring the descryptor also involves streaming in CPBEncryptionData object as well as the cipher text.

This example has purposly not destroyed and recreated the CPBEncryptionData and CPBEncryptElement due to size

CPBDecryptor* decrypter = data->NewDecryptLC();
HBufC8* plaintext = HBufC8::NewLC( decrypter->MaxFinalOutputLength( 
                                                     ciphertext->Length()));
TPtr8 plaintextPtr = plaintext->Des();
decrypter->ProcessFinalL(*ciphertext, plaintextPtr);
// plaintext now contains the unencrypted data
CleanupStack::PopAndDestroy(5, data);

Related Discussions

Thread Thread Starter Forum Replies Last Post
bluetooth with 6021 hhl0519 Bluetooth Technology 0 2005-07-26 02:46
Does WML support encryption? cyntellitek Browsing and Mark-ups 1 2002-12-17 07:13
Problems installing Audio Suite cagozzo Audio 0 2007-08-26 15:26
资源出错,R_LOCALISABLE_APP_INFO,Label not found lius1984 Symbian 18 2008-09-17 09:16
query related to encryption manikantan Flash Lite on Nokia Devices 1 2008-08-29 19:15

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditFurlTechnocratiMagnoliaTwitter  Share this page Share this page Invite a friend Invite a friend
E-mail Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us Regional websites: Chinese Japanese © 2008 Nokia 
RDF Facets: qfnZtypeQUqfnTypeZCommunityContentQ qfnZtypeQUqfnTypeZWebpageQ qfnZtypeQUqfnTypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX