X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/a503f71d90ef2d1946c0088e01513805092f3cce..a1ac08a57a9e6c12c850494de412941edf7dbdf9:/IDA/ida.cpp?ds=sidebyside diff --git a/IDA/ida.cpp b/IDA/ida.cpp index 9a1d31b..e854c3a 100644 --- a/IDA/ida.cpp +++ b/IDA/ida.cpp @@ -1,6 +1,3 @@ -// g++ -std=c++11 -O4 -msse2 -msse3 -msse4 -fopenmp -O3 test_mat2.cpp -o test_mat2 -I /home/couturie/tools/armadillo-6.200.5/include/ -lc -lm -lpthread -lgfortran -DMAX_STACK_ALLOC=2048 -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=8 -DNO_AFFINITY -UCOMPLEX -DDOUBLE -I/home/couturie/tools/openblas/include -I/home/couturie/Downloads/OpenBLAS-0.2.15/ /home/couturie/tools/openblas/lib/libopenblas_haswellp-r0.2.15.a - - #include <armadillo> #include <stdlib.h> @@ -158,13 +155,16 @@ convert_vec250_to_vec256(vector<uint8_t> vec250){ Mat<byte> readFullFile(int n, int k, long& sizeFile, int &lc) { // ifstream stream("lena.png", ios::in | ios::binary | ios::ate); - ifstream stream("/home/couturie/Downloads/CARCARIASS.zip", ios::in | ios::binary | ios::ate); -// ifstream stream("lena_small2.png", ios::in | ios::binary | ios::ate); + ifstream stream("lena_small2.png", ios::in | ios::binary | ios::ate); +// ifstream stream("/home/couturie/Downloads/CARCARIASS.zip", ios::in | ios::binary | ios::ate); + sizeFile=stream.tellg(); cout<<sizeFile<<endl; stream.seekg(0, ios::beg); + +//Used to convert the size (in long) in 8 bytes uint8_t mysize[8]; @@ -176,6 +176,7 @@ Mat<byte> readFullFile(int n, int k, long& sizeFile, int &lc) { tmpSize>>=8; } +//we rebuild the size in order to check that the routine is correct cout<<"rebuild"<<endl; long res=0; for(int i=8-1;i>=0;i--) { @@ -193,6 +194,14 @@ Mat<byte> readFullFile(int n, int k, long& sizeFile, int &lc) { // for(int i=0;i<8;i++) // contents.insert(i,mysize[i]); contents.insert (contents.begin(), mysize, mysize+8); + + cout<<"start of the vector"<<endl; + for(int i=0;i<8;i++) + cout<<(int)contents[i]<<" "; + cout<<endl; + + + cout<<"res contents "<<contents.size()<<endl; vector<uint8_t> contents2=convert_vec256_to_vec250(contents); cout<<"res contents2 "<<contents2.size()<<endl; @@ -218,8 +227,8 @@ if (std::equal(contents.begin(), contents.begin() + contents.size(), contents3.b cout << "success" << endl; */ -lc=ceil(contents2.size()/k); - cout<<lc<<endl; + lc=ceil(contents2.size()/k); + cout<<"size lc "<<lc<<endl; Mat<byte> matData(&contents2[0],1,contents2.size()); @@ -242,12 +251,9 @@ int main( int argc, char *argv[] ) { - int full=0; int n=8; int k=4; - int Tb=64; - int l=10;//399*Tb; @@ -292,14 +298,21 @@ int main( int argc, char *argv[] ) { cout<<"tatat"<<endl; Mat<byte> C3; + + int off=0; + //read k files among n - for(int i=0;i<k;i++) { + + int l=0; +// for(int i=k-1;i>=0;i--) { + for(int i=0+off;i<k+off;i++) { stringstream ss; ss <<"lena_"<<i<<".png"; string str = ss.str(); - + cout<<str<<endl; Row<byte> d2=readFile(str.c_str()); - C3.insert_rows(i,d2); + C3.insert_rows(l,d2); + l++; } @@ -310,6 +323,7 @@ int main( int argc, char *argv[] ) { Mat<int> Cs=conv_to<Mat<int>>::from(C3); cout<<size(Cs)<<" "<<size(C3)<<endl; + cout<<"S "<<" "<<S<<endl; @@ -331,7 +345,6 @@ int main( int argc, char *argv[] ) { mat Gsi=round(inv(Gs)*det(Gs)*r); Gsi=mod(Gsi,mm); - Gsi=mod(Gsi,mm); cout<<Gsi<<endl; @@ -339,9 +352,9 @@ int main( int argc, char *argv[] ) { mat SS2=mod(temp,mm); Mat<byte> S2=conv_to<Mat<byte>>::from(SS2); S2=mod(S2,mm); -// cout<<S2<<endl; -// cout<<"max"<<endl; -// cout<<max(S2-S,1)<<endl; + cout<<"S2 "<<S2<<endl; + cout<<"max"<<endl; + cout<<max(S2-S,1)<<endl; @@ -351,6 +364,13 @@ int main( int argc, char *argv[] ) { vector<uint8_t> res =conv_to< vector<uint8_t> >::from(S2.row(0)); cout<<"res size "<<res.size()<<endl; + + cout<<"start of file"<<endl; + for(int i=0;i<8;i++) + cout<<(int)res[i]<<" "; + cout<<endl; + + vector<uint8_t> res2=convert_vec250_to_vec256(res); cout<<"res2 size "<<res2.size()<<endl;