From: Raphaƫl Couturier Date: Wed, 16 Jun 2021 11:52:48 +0000 (+0200) Subject: add X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/commitdiff_plain/fb12494aee99738f9daab81fad888d1a45b5cb34?ds=inline;hp=49d265094698dee951c0a0bf97f8183cf171f57b add --- diff --git a/CipherImg/test_sub_perm.cpp b/CipherImg/test_sub_perm.cpp new file mode 100644 index 0000000..b52d167 --- /dev/null +++ b/CipherImg/test_sub_perm.cpp @@ -0,0 +1,134 @@ +//g++ test_sub_perm.cpp -o test_sub_perm -O3 -fpermissive + + +// ./test_sub_perm sizebuf512 nb1000 + +#include +#include +#include +#include +#include + + +using namespace std; + +typedef unsigned char uchar; + + + +int nb_test=1; +int ctr=0; + +double time_encrypt=0; +double time_decrypt=0; + +double TimeStart() +{ + struct timeval tstart; + gettimeofday(&tstart,0); + return( (double) (tstart.tv_sec + tstart.tv_usec*1e-6) ); +} + +double TimeStop(double t) +{ + struct timeval tend; + + gettimeofday(&tend,0); + t = (double) (tend.tv_sec + tend.tv_usec*1e-6) - t; + return (t); +} + + + + +void rc4key(uchar *key, uchar *sc, int size_DK) { + + for(int i=0;i<256;i++) { + sc[i]=i; + } + + + uchar j0 = 0; + for(int i0=0; i0<256; i0++) { + j0 = (j0 + sc[i0] + key[i0%size_DK] )&0xFF; + uchar tmp = sc[i0]; + sc[i0] = sc[j0 ]; + sc[j0] = tmp; + } +} + + +int main (int argc, char** argv) +{ + /* Set up the key and iv. Do I need to say to not hard code these in a + * real application? :-) + */ + + int size_buf=1; + int lena=0; + + + for(int i=1; i