-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add speed test * delete using namespace std
- Loading branch information
Showing
9 changed files
with
148 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
#include <iostream> | ||
#include "../src/AES.h" | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
cout << "Aes dev" << endl; | ||
std::cout << "Aes dev" << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <iostream> | ||
#include <sys/time.h> | ||
#include <ctime> | ||
#include "../src/AES.h" | ||
|
||
const unsigned int MICROSECONDS = 1000000; | ||
unsigned long getMicroseconds() | ||
{ | ||
struct timeval tv; | ||
gettimeofday(&tv,NULL); | ||
return MICROSECONDS * tv.tv_sec + tv.tv_usec; | ||
} | ||
|
||
unsigned char * getRandomPlain(unsigned int length) | ||
{ | ||
unsigned char *plain = new unsigned char[length]; | ||
for (unsigned int i = 0; i < length; i++) { | ||
plain[i] = rand() % 256; | ||
} | ||
|
||
return plain; | ||
|
||
} | ||
|
||
int main() | ||
{ | ||
const unsigned int MEGABYTE = 1024 * 1024 * sizeof(unsigned char); | ||
|
||
unsigned int len = 0; | ||
unsigned int megabytesCount = 10; | ||
unsigned int plainLength = megabytesCount * MEGABYTE; | ||
unsigned char key[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; | ||
|
||
std::cout << "Start speedtest" << std::endl; | ||
srand(std::time(nullptr)); | ||
|
||
unsigned char *plain = getRandomPlain(plainLength); | ||
|
||
AES aes(AESKeyLength::AES_256); | ||
unsigned long start = getMicroseconds(); | ||
unsigned char *out = aes.EncryptECB(plain, plainLength, key, len); | ||
unsigned long delta = getMicroseconds() - start; | ||
|
||
double speed = (double)megabytesCount / delta * MICROSECONDS; | ||
|
||
printf("%.2f Mb/s\n", speed); | ||
|
||
delete[] plain; | ||
delete[] out; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.