the sample-code in crypto++5.0 (test.cpp) nearly has
all i need... but i want to encrypt a message using a
private key (and decrypt with the public).
how can i change this simple code-snippets to encrypt
with private and decrypt with the public key?
i am used somewhat used to c++, read the documentation
and spent some days wiht the source, but.. (its really
hardcode c++, looks to me if c++ was used to encrypt
the code:).

can someone help?

yes: i know that this is not the common thing you are
expected to do with rsa, but i need it in an
environment where it definitly makes (would make if
you can help me:) sense.

string RSAEncryptString(const char *pubFilename, const
char *seed, const
char *message)

{
 FileSource pubFile(pubFilename, true, new
HexDecoder);
 RSAES_OAEP_SHA_Encryptor pub(pubFile);

 RandomPool randPool;
 randPool.Put((byte *)seed, strlen(seed));

 string result;
 StringSource(message, true, new
PK_EncryptorFilter(randPool, pub, new
HexEncoder(new StringSink(result))));
 return result;
}

string RSADecryptString(const char *privFilename,
const char *ciphertext)
{
 FileSource privFile(privFilename, true, new
HexDecoder);
 RSAES_OAEP_SHA_Decryptor priv(privFile);

 string result;
 StringSource(ciphertext, true, new HexDecoder(new
PK_DecryptorFilter(priv,
new StringSink(result))));
 return result;
}


__________________________________________________________________

Gesendet von Yahoo! Mail - http://mail.yahoo.de
Bis zu 100 MB Speicher bei http://premiummail.yahoo.de

Reply via email to