/[resiprocate]/main/sip/resiprocate/test/testRandomHex.cxx
ViewVC logotype

Diff of /main/sip/resiprocate/test/testRandomHex.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 537 by jason, Thu Nov 7 03:07:27 2002 UTC revision 712 by fluffy, Sat Nov 23 22:06:27 2002 UTC
# Line 3  Line 3 
3  #include <set>  #include <set>
4    
5  #include "sip2/util/Data.hxx"  #include "sip2/util/Data.hxx"
6  #include "sip2/util/RandomHex.hxx"  #include "sip2/util/Random.hxx"
7    
8  using namespace std;  using namespace std;
9  using namespace Vocal2;  using namespace Vocal2;
# Line 19  Line 19 
19     int runs = atoi(argv[1]);     int runs = atoi(argv[1]);
20     int length = atoi(argv[2]);     int length = atoi(argv[2]);
21    
22       Random::initialize();
23      
24    
25     if (runs <= 0 || length <= 0)     if (runs <= 0 || length <= 0)
26     {     {
27        cerr << "usage: testRandomHex number_of_tries string_length" << endl        cerr << "usage: testRandomHex number_of_tries string_length" << endl
# Line 32  Line 35 
35        
36     for (int i = 0; i < runs; i++)     for (int i = 0; i < runs; i++)
37     {     {
38        Data foo = RandomHex::get(length);        Data foo = Random::getRandomHex(length);
39  //      cerr << foo << endl;        cerr << foo << endl;
40        if (randomDatas.insert(foo).second == false)        if (randomDatas.insert(foo).second == false)
41        {        {
42           cerr << "RandomHex produced a duplicate" << length << "byte string after " << i << " runs. " << endl;           cerr << "RandomHex produced a duplicate" << length << "byte string after " << i << " runs. " << endl;
43           exit(-1);           exit(-1);
44        }        }
45     }     }
46    
47       cerr << endl << "Now doing crypto random" << endl;
48      
49       for (int i = 0; i < runs; i++)
50       {
51          Data foo = Random::getCryptoRandomHex(length);
52          cerr << foo << endl;
53          if (randomDatas.insert(foo).second == false)
54          {
55             cerr << "RandomHex produced a duplicate" << length << "byte string after " << i << " runs. " << endl;
56             exit(-1);
57          }
58       }
59    
60     cerr << "Success." << endl;     cerr << "Success." << endl;
61  }  }
62    

Legend:
Removed from v.537  
changed lines
  Added in v.712

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27