Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Generates C code that initialises a variable to hold some random data.
26 #include <openssl/rand.h>
28 static void gen_random(int len)
30 unsigned char data[len];
33 RAND_bytes(data, len);
35 printf("unsigned char random[] =");
36 for (i = 0 ; i < sizeof(data) ; i += 16)
39 for (j = i ; j < sizeof(data) && j < (i + 16) ; ++j)
41 printf("\\x%02x", data[j]);
49 static void badUsage()
51 printf("gen_random [BYTES]\n");
55 int main(int argc, char* argv[])
63 bytes = atoi(argv[1]);