I am implementing RSA algorithm in C++ and here's my design(code structure).
keygen.h
namespace rsa{
class keygen{
public:
//Constructor
keygen(size);
//Generate keys
void generate();
//Getters
char* gete(){ return xyz; }
..
..
..
private:
//initializes bignums
void initall();
//Private Member variables goes here
}
}
prime.h
namespace rsa{
//First 100 primes
unsigned int primes[]={2,3,5,7,11.....541};
//MillarRabin Primality
bool isPrime(mpz_t, unsigned short);
//Get Random Prime
void getPrime(mpz_t, mpz_t)
}
endec.h
namespace rsa{
//Encryption
const char* encryption(const char* text, const char* n, const char* e);
//Decryption
const char* decryption(const char* cipher, const char* n, const char* d);
}
Is this a good design? How can I make it better? I want to improve the structure or the overall design, that's why dint post any code. Things like naming standards, using classes wherever applicable, standard function signature and similar is what I'm looking for.
Keygen
instead ofkeygen
for a class name". – Michael Apr 23 '12 at 16:31encrypt()
decrypt()
functions. And what is with passing char* pointers around use std::string to represent a password or create aKey
type to represent a key etc. – Loki Astari Apr 23 '12 at 17:10