From f49e2058ad2c6d7eedded27fa41bd30405db5aaa Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 8 Oct 2016 11:56:47 +0200 Subject: Make parameter order a bit more consistent --- aes.cpp | 12 ++++++------ aes.h | 4 ++-- main.cpp | 4 ++-- rsa.cpp | 6 ++++-- rsa.h | 4 ++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/aes.cpp b/aes.cpp index e226a3c..7048b17 100644 --- a/aes.cpp +++ b/aes.cpp @@ -174,7 +174,7 @@ namespace AES{ addRoundKey(state,keysched); } - string encryptCBC(const string &key,const string &data,int numrounds){ + string encryptCBC(const string &data,const string &key,int numrounds){ if(roundconstant[0]==0)initTables(); int sz=data.size(); @@ -211,7 +211,7 @@ namespace AES{ return res; } - string decryptCBC(const string &key,const string &data,int numrounds){ + string decryptCBC(const string &data,const string &key,int numrounds){ if(roundconstant[0]==0)initTables(); if(data.size()==0)return {}; @@ -232,7 +232,7 @@ namespace AES{ return res; } - string encrypt(const string &key,const string &data,Algorithm algo){ + string encrypt(const string &data,const string &key,Algorithm algo){ int increment; switch(algo){ case AES_128_CBC: increment=0; break; @@ -241,10 +241,10 @@ namespace AES{ default: assert(false); } assert((int)key.size()==4*(4+2*increment)); - return encryptCBC(key,data,10+2*increment); + return encryptCBC(data,key,10+2*increment); } - string decrypt(const string &key,const string &data,Algorithm algo){ + string decrypt(const string &data,const string &key,Algorithm algo){ int increment; switch(algo){ case AES_128_CBC: increment=0; break; @@ -253,7 +253,7 @@ namespace AES{ default: assert(false); } assert((int)key.size()==4*(4+2*increment)); - return decryptCBC(key,data,10+2*increment); + return decryptCBC(data,key,10+2*increment); } void test(){ diff --git a/aes.h b/aes.h index b2064f2..0532a62 100644 --- a/aes.h +++ b/aes.h @@ -10,10 +10,10 @@ namespace AES{ AES_256_CBC, }; - std::string encrypt(const std::string &key,const std::string &data,Algorithm algo); + std::string encrypt(const std::string &data,const std::string &key,Algorithm algo); //throws invalid_argument for an invalid ciphertext (length not a multiple of block size, or padding malformed) - std::string decrypt(const std::string &key,const std::string &data,Algorithm algo); + std::string decrypt(const std::string &data,const std::string &key,Algorithm algo); void test(); diff --git a/main.cpp b/main.cpp index 0481f6c..60198f7 100644 --- a/main.cpp +++ b/main.cpp @@ -143,9 +143,9 @@ void performrsa(){ cout<<"d = "<