prgtest.cpp
Go to the documentation of this file.
1 
15 #include <iostream>
16 #include <iomanip>
17 
18 
19 #include "cryptotools.hpp"
20 
21 using namespace cryptoTools;
22 
23 
24 int main(void)
25 {
26  SHAx * hash;
27  PRG * p;
28  std::vector<uint8_t> seed;
29 
30  // Testing with SHA-256
31 
32  std::cout<<"SHA-256";
33  hash = new SHA256();
34  p = new PRG(hash);
35  seed.clear();
36  for (uint8_t byte=0; byte<32; byte++)
37  seed.push_back(byte);
38  p->initialize(seed);
39  for (unsigned int i=0; i<128; i++)
40  {
41  if ((i%32)==0)
42  std::cout<<std::endl;
43  std::cout<<std::hex<<std::setfill('0')
44  <<std::setw(2)<<(int)p->getNextRandByte();
45  }
46  std::cout<<std::endl;
47 
48 
49  // Testing with SHA-384
50 
51  std::cout<<std::endl<<"SHA-384";
52  hash = new SHA384();
53  p = new PRG(hash);
54  seed.clear();
55  for (uint8_t byte=0; byte<48; byte++)
56  seed.push_back(byte);
57  p->initialize(seed);
58  for (unsigned int i=0; i<128; i++)
59  {
60  if ((i%32)==0)
61  std::cout<<std::endl;
62  std::cout<<std::hex<<std::setfill('0')
63  <<std::setw(2)<<(int)p->getNextRandByte();
64  }
65  std::cout<<std::endl;
66 
67 
68  // Testing with SHA-512
69 
70  std::cout<<std::endl<<"SHA-512";
71  hash = new SHA512();
72  p = new PRG(hash);
73  seed.clear();
74  for (uint8_t byte=0; byte<64; byte++)
75  seed.push_back(byte);
76  p->initialize(seed);
77  for (unsigned int i=0; i<128; i++)
78  {
79  if ((i%32)==0)
80  std::cout<<std::endl;
81  std::cout<<std::hex<<std::setfill('0')
82  <<std::setw(2)<<(int)p->getNextRandByte();
83  }
84  std::cout<<std::endl;
85 
86  return 0;
87 }