Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:Creating Random Numbers in Symbian

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Tested with
Devices(s): Nokia N97
Platform(s): S60 3rd Edition
S60 3rd Edition (initial release)
Keywords: TRandom
Created: Paul.Todd (04 Feb 2010)
Last edited: hamishwillee (18 Jun 2012)



Random value generation in Symbian C++ can be done with the TRandom API. This calls into the OS to gen a pseudo random number stream based on the size of the supplied descriptor

This snippet can be self-signed.

MMP file

The following libraries are required:

LIBRARY euser.lib

Source file

#include <random.h>
int main (void)
// if we want 10 random bytes of data..
TBuf8<10> prngData;
prngData.SetLength( prngData.MaxLength() );
// prngData now has the random data in it.
// Of course HBufC8* could be used to reduce stack space
return 0;


10 random numbers are generated

This page was last modified on 18 June 2012, at 23:23.
28 page views in the last 30 days.