From fb12494aee99738f9daab81fad888d1a45b5cb34 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Couturier?= Date: Wed, 16 Jun 2021 13:52:48 +0200 Subject: [PATCH] add --- CipherImg/test_sub_perm.cpp | 134 ++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 CipherImg/test_sub_perm.cpp 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