Symbian3/PDK/Source/GUID-267D1E20-002E-53C7-8AE5-E063206C1562.dita
changeset 12 80ef3a206772
parent 11 5072524fcc79
child 13 48780e181b38
--- a/Symbian3/PDK/Source/GUID-267D1E20-002E-53C7-8AE5-E063206C1562.dita	Fri Jul 02 12:51:36 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
-<!-- This component and the accompanying materials are made available under the terms of the License 
-"Eclipse Public License v1.0" which accompanies this distribution, 
-and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
-<!-- Initial Contributors:
-    Nokia Corporation - initial contribution.
-Contributors: 
--->
-<!DOCTYPE concept
-  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
-<concept xml:lang="en" id="GUID-267D1E20-002E-53C7-8AE5-E063206C1562"><title>Secure stream encryption example support code</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>Below is the supporting code for the <xref href="GUID-598B6698-3518-50CA-98DE-D85CB255BA2D.dita">secure stream example code</xref>. </p> <section id="GUID-77E39C51-FE08-4EEB-B94A-4ECD8104E1ED"><title/><codeblock id="GUID-02ECEC04-E291-51B3-86DF-2FB28347F5AD" xml:space="preserve">
-#include "e32std.h"
-#include "f32file.h"
-#include "s32file.h"
-#include "pbe.h"
-#include "pbedata.h"
-#include "s32crypt.h"
-            </codeblock> <codeblock id="GUID-13A09565-981A-56C0-9AC7-B849FFBE7395" xml:space="preserve">
-/*
- * Class to demonstrate the use of secure stream encryption APIs.
- */
-class CSecureStreamExample : public CBase
-         {
-public:
-         static CSecureStreamExample* NewLC();
-         virtual ~CSecureStreamExample();
-         
-         void WriteEncryptedDataL(const TDesC8&amp; aInput, const TDesC&amp; aFilename, const TDesC&amp; aPassword);
-         HBufC8* ReadEncryptedDataLC(const TDesC&amp; aFilename, const TDesC&amp; aPassword);
-private:
-         CSecureStreamExample();
-         void ConstructL();
-private:
-         RFs iFs;
-         };
-            </codeblock> <codeblock id="GUID-B23E19C7-F6AD-5CB4-A944-EFEDC45AB623" xml:space="preserve">
-CSecureStreamExample* CSecureStreamExample::NewLC()
-         {
-         CSecureStreamExample* self = new (ELeave) CSecureStreamExample();
-         CleanupStack::PushL(self);
-         self-&gt;ConstructL();
-         return self;
-         }
-
-CSecureStreamExample::CSecureStreamExample()
-         {
-         }
-
-void CSecureStreamExample::ConstructL()
-         {
-         User::LeaveIfError(iFs.Connect());
-         }
-
-CSecureStreamExample::~CSecureStreamExample()
-         {
-         iFs.Close();
-         }
-            </codeblock> <codeblock id="GUID-11B8C0DD-AD05-53BB-BAD2-6F31457A2DD9" xml:space="preserve">
-LOCAL_D void RunPBEExampleL()
-         {
-         _LIT(KFilename, "c:\\pbe_example_data.dat");
-         _LIT8(KInputData, "This is the data to be encrypted.");
-         _LIT(KPassword, "pa55w0rd");
-
-         CSecureStreamExample* main = CSecureStreamExample::NewLC();
-         main-&gt;WriteEncryptedDataL(KInputData, KFilename, KPassword);
-         HBufC8* outputData = main-&gt;ReadEncryptedDataLC(KFilename, KPassword);
-         ASSERT(*outputData == KInputData);
-         CleanupStack::PopAndDestroy(2, main);
-         }
-            </codeblock> <codeblock id="GUID-0B93114C-6801-5053-85C3-181779A6185F" xml:space="preserve">
-GLDEF_C TInt E32Main() // main function called by E32
-    {
-         __UHEAP_MARK;
-         CTrapCleanup* cleanup = CTrapCleanup::New(); // get clean-up stack
-         TRAPD(error, RunPBEExampleL());
-         __ASSERT_ALWAYS(!error,User::Panic(_L("pbe_example_code"),error));
-         delete cleanup; // destroy clean-up stack
-         __UHEAP_MARKEND;
-         return 0;
-    }
-        </codeblock> </section> </conbody></concept>
\ No newline at end of file