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);
| 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 |