Click here to Skip to main content
15,900,725 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMFC, Threads and Responsive GUI Pin
Member 296436524-Apr-12 2:10
Member 296436524-Apr-12 2:10 
AnswerRe: MFC, Threads and Responsive GUI Pin
JohnCz24-Apr-12 2:35
JohnCz24-Apr-12 2:35 
GeneralRe: MFC, Threads and Responsive GUI Pin
krmed24-Apr-12 10:31
krmed24-Apr-12 10:31 
GeneralRe: MFC, Threads and Responsive GUI Pin
JohnCz24-Apr-12 11:11
JohnCz24-Apr-12 11:11 
AnswerRe: MFC, Threads and Responsive GUI Pin
Rajesh R Subramanian25-Apr-12 3:59
professionalRajesh R Subramanian25-Apr-12 3:59 
AnswerRe: MFC, Threads and Responsive GUI Pin
Eytukan27-Apr-12 3:27
Eytukan27-Apr-12 3:27 
QuestionDesign Practices, implementing RSA Pin
Vidit Ochani24-Apr-12 2:00
Vidit Ochani24-Apr-12 2:00 
AnswerRe: Design Practices, implementing RSA Pin
Aescleal24-Apr-12 4:28
Aescleal24-Apr-12 4:28 
Hi,

I'd get rid of the private member functions and use a PIMPL [1] for your key generator class. It clears a lot of stuff out of the header file and makes that a bit easier to use. If you can end up with something minimal it doesn't help people using your code. Perhaps something like:

C++
class key_generator_data;

class key_generator
{
    public:
        key_generator( const unsigned key_size );

        key_pair create_new_key() const;

    private:
        std::unique_ptr<key_generator_data> data_;
};

And that's it with key_pair, public_key and private_key being classes.

The only other thing I'd comment on would be what your encryption and decryption functions are called and the parameters they take. Perhaps consider having a stream interface as well?

C++
bool encrypt( std::istream &plain_text, std::ostream &cypher_text, const std::string &n, const std::string &e );

bool decrypt( std::istream &cypher_text, std::ostream &plain_text, const std::string &n, const std::string &d );


Perhaps have better naming for the public and private keys as well.

I know that you don't generally encode much with RSA but stream interfaces make it a lot easier to encrypt and decrypt stuff. You can test stuff by entering plain text at the console, reading it from a file or even over a socket without the caller having to buffer anything.

One final point... If you intend doing anything else it might be worth making an abstract base encryptor class and implementing your code in terms of that. Then if you ever decide to use a different asymmetric encryption algorithm or want to unit test client code you can just in a replacement.

Cheers,

Ash

[1] Herb Sutter describes what a PIMPL is in "Exceptional C++". They're a great way of avoiding all the nightmares that come with cluttered interfaces.
GeneralRe: Design Practices, implementing RSA Pin
Vidit Ochani25-Apr-12 0:33
Vidit Ochani25-Apr-12 0:33 
GeneralRe: Design Practices, implementing RSA Pin
Aescleal25-Apr-12 5:15
Aescleal25-Apr-12 5:15 
GeneralRe: Design Practices, implementing RSA Pin
Vidit Ochani25-Apr-12 10:02
Vidit Ochani25-Apr-12 10:02 
GeneralRe: Design Practices, implementing RSA Pin
Aescleal27-Apr-12 1:35
Aescleal27-Apr-12 1:35 
QuestionButton Color In MFC Pin
002comp24-Apr-12 0:40
002comp24-Apr-12 0:40 
AnswerRe: Button Color In MFC Pin
JohnCz24-Apr-12 2:38
JohnCz24-Apr-12 2:38 
GeneralRe: Button Color In MFC Pin
002comp24-Apr-12 2:42
002comp24-Apr-12 2:42 
AnswerRe: Button Color In MFC Pin
David Crow24-Apr-12 2:39
David Crow24-Apr-12 2:39 
GeneralRe: Button Color In MFC Pin
002comp24-Apr-12 2:44
002comp24-Apr-12 2:44 
GeneralRe: Button Color In MFC Pin
David Crow24-Apr-12 6:40
David Crow24-Apr-12 6:40 
AnswerRe: Button Color In MFC Pin
jeron124-Apr-12 3:58
jeron124-Apr-12 3:58 
AnswerRe: Button Color In MFC Pin
JohnCz24-Apr-12 4:08
JohnCz24-Apr-12 4:08 
QuestionRe: Button Color In MFC Pin
David Crow24-Apr-12 6:04
David Crow24-Apr-12 6:04 
AnswerRe: Button Color In MFC Pin
JohnCz24-Apr-12 7:42
JohnCz24-Apr-12 7:42 
GeneralRe: Button Color In MFC Pin
enhzflep24-Apr-12 8:13
enhzflep24-Apr-12 8:13 
GeneralRe: Button Color In MFC Pin
JohnCz24-Apr-12 10:55
JohnCz24-Apr-12 10:55 
GeneralRe: Button Color In MFC Pin
002comp24-Apr-12 20:31
002comp24-Apr-12 20:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.