|
1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: DM-settings |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "nsmldmsettings.h" |
|
22 |
|
23 |
|
24 //------------------------------------------------------------------------------ |
|
25 // |
|
26 // CNSmlDMCrypt |
|
27 // |
|
28 //------------------------------------------------------------------------------ |
|
29 |
|
30 //------------------------------------------------------------------------------ |
|
31 // CNSmlDMCrypt::CNSmlDMCrypt() |
|
32 // Constructor. |
|
33 //------------------------------------------------------------------------------ |
|
34 EXPORT_C CNSmlDMCrypt::CNSmlDMCrypt() |
|
35 { |
|
36 } |
|
37 |
|
38 //------------------------------------------------------------------------------ |
|
39 // CNSmlDMCrypt::~CNSmlDMCrypt() |
|
40 // Destructor. |
|
41 //------------------------------------------------------------------------------ |
|
42 EXPORT_C CNSmlDMCrypt::~CNSmlDMCrypt() |
|
43 { |
|
44 delete iOutput; |
|
45 } |
|
46 |
|
47 //------------------------------------------------------------------------------ |
|
48 // CNSmlDMCrypt::EncryptedL() |
|
49 // Encrypts |
|
50 //------------------------------------------------------------------------------ |
|
51 EXPORT_C TDesC& CNSmlDMCrypt::EncryptedL( const TDesC& aInput ) |
|
52 { |
|
53 delete iOutput; |
|
54 iOutput = 0; |
|
55 |
|
56 iOutput = aInput.AllocL(); |
|
57 |
|
58 TPtr ptrOutput( iOutput->Des() ); |
|
59 |
|
60 // Key definitions to be used in encryption |
|
61 TUint16 key1 = 0xa576; |
|
62 TUint16 key2 = 0x02f9; |
|
63 |
|
64 for (TInt i = 0; i < iOutput->Length(); i++ ) |
|
65 { |
|
66 key1 %= key2; |
|
67 key1 <<= 7; |
|
68 key1 ^= key2; |
|
69 key2 %= key1; |
|
70 key2 <<= 3; |
|
71 key2 ^= key1; |
|
72 ptrOutput[i] ^= key1; |
|
73 } |
|
74 |
|
75 return *iOutput; |
|
76 } |
|
77 |
|
78 //------------------------------------------------------------------------------ |
|
79 // CNSmlDMCrypt::DecryptedL() |
|
80 // Destructor. |
|
81 //------------------------------------------------------------------------------ |
|
82 EXPORT_C TDesC& CNSmlDMCrypt::DecryptedL( const TDesC& aInput ) |
|
83 { |
|
84 return EncryptedL( aInput ); |
|
85 } |
|
86 |
|
87 // End of File |