equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2005-2009 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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 */ |
|
24 |
|
25 #include "tbrokenrandom.h" |
|
26 |
|
27 /* CRandomSetSeed */ |
|
28 CRandomSetSource::CRandomSetSource(const TDesC8& aSource) |
|
29 { |
|
30 SetSource(aSource); |
|
31 } |
|
32 |
|
33 void CRandomSetSource::GenerateBytesL(TDes8& aDest) |
|
34 { |
|
35 if(aDest.Size() <= iValue.Size() - (TInt)iCounter) |
|
36 { |
|
37 for (int i = 0 ; i < aDest.Length() ; ++i) |
|
38 { |
|
39 aDest[i] = iValue[iCounter]; |
|
40 iCounter++; |
|
41 } |
|
42 } |
|
43 else |
|
44 { |
|
45 TRandom::RandomL(aDest); |
|
46 } |
|
47 } |
|
48 |
|
49 void CRandomSetSource::SetSource(const TDesC8& aSource) |
|
50 { |
|
51 iValue.Set(aSource); |
|
52 iCounter = 0; |
|
53 } |
|
54 |
|
55 /* CRandomIncrementing */ |
|
56 CRandomIncrementing::CRandomIncrementing(TUint aInitialValue) |
|
57 { |
|
58 iValue = aInitialValue; |
|
59 } |
|
60 |
|
61 void CRandomIncrementing::GenerateBytesL(TDes8& aDest) |
|
62 { |
|
63 for (int i = 0 ; i < aDest.Length() ; ++i) |
|
64 { |
|
65 aDest[i] = (char)(iValue)++; |
|
66 } |
|
67 } |