2014-10-06 22 views

回答

0

從OpenSSL的應用程序,你可以簡單的寫了下面的命令:

openssl speed aes-128-cbc des-ede3 

或者你可以簡單地寫一個C程序檢查速度。

AES_KEY    keyaes; 
    DES_key_schedule desk1; 
    int    index; 
    char srcbuf[16]; 
    char    dest[16]; 
    char    dest2[16]; 


//Set the keys. 
memcpy (deskey, "abcdefgh", sizeof("abcdefg")); 
memcpy (aeskey, "abcdefghijklmnop", sizeof("abcdefghijklmno")); 

AES_set_decrypt_key((const unsigned char *)aeskey, 256, &keyaes2); 
AES_set_encrypt_key((const unsigned char *)aeskey, 256, &keyaes); 
AES_set_decrypt_key((const unsigned char *)aeskey, 128, &keyaes128); 
AES_set_encrypt_key((const unsigned char *)aeskey, 128, &keyaes1282); 

DES_key_sched ((const_DES_cblock *)deskey, &desk1); 
DES_key_sched ((const_DES_cblock *)deskey, &desk2); 
DES_key_sched ((const_DES_cblock *)deskey, &desk3); 

memset(srcbuf, 0, AES_BLOCK_SIZE); 

//Encrypt 64 times. 
//AES 
clock_t start = clock(); 
for(index = 0; index < 4096*4; ++index) { 
    AES_encrypt ((const unsigned char *)srcbuf, (unsigned char *)dest, &keyaes); 
} 
clock_t stop = clock(); 

//DES 
start = clock(); 
for(index = 0; index < 4096*4; ++index) { 
    //AES is encrypting 128 bytes, so it should also encrypt 128 bytes. 
    DES_encrypt3 ((DES_LONG *)srcbuf, &desk1, &desk2, &desk3); 
    DES_encrypt3 ((DES_LONG *)(srcbuf + sizeof(DES_LONG)), &desk1, &desk2, &desk3); 
} 
stop = clock(); 

現在,請注意區別。

+0

謝謝,但我正在尋找一個命令來告訴我什麼時候加密一個特定的文件。 在Linux中,時間命令告訴你。 – chisky 2014-10-11 15:05:59