It´s something like this:

CString CInfoFormat::EncriptarCadena(CString Entrada)
{
        CryptoPP::RandomPool randPool;
        seed = _T("This is the seed!");
        randPool.Put((byte *)seed, strlen(seed));

        CryptoPP::RSAES_PKCS1v15_Encryptor encodeador;
        
encodeador.AccessKey().Initialize(CryptoPP::Integer("h93880B9999427FFFBD189F
66CD1D0E165B75BC6B68EA68DC42DBD9C095861E89F4F20793EEE66DFB23A3269F6BFD10B408
32EA144C7BDA06DBA8E992F0D15E9C9EAE92B0D9B6D8FED6CC5EE947004B588F6395C7BA7B2F
7A36336E40211C2F5C543FDB7C28C5956FCC448C3C07FBB2C26B5CF49E45B46E12ACE8BD2637
493EC9"),
CryptoPP::Integer("h99CEB83B184A0CA0F9FFF26792F44CBF1532799BABB18C9F1E998792
3AAEF142BD30C0F5E0464051A4E860E29B06EA9CD7AEDB5E1454CD06793EB355B2838293"));

        char *outstr = new char[Entrada.GetLength()*10];

        encodeador.Encrypt(randPool,(byte
*)Entrada.GetBuffer(),Entrada.GetLength(),(byte *)outstr);

        /*CryptoPP::HexEncoder hexEncoder;
        hexEncoder.Put((byte *)outstr,
encodeador.CiphertextLength(Entrada.GetLength()));
        hexEncoder.MessageEnd();
        hexEncoder.Get((byte *)outstr,
2*encodeador.CiphertextLength(Entrada.GetLength()));
        outstr[2*encodeador.CiphertextLength(Entrada.GetLength())] = 0;*/
        CString csRet;
        csRet.SetString(outstr.c_str(),outstr.size());

        return csRet;
}
CString CInfoFormat::DesEncriptarCadena(CString Entrada)
{
        CryptoPP::RandomPool randPool;
        randPool.Put((byte *)seed, strlen(seed));
        //CryptoPP::StringSource
cad("hF58DD26DD8E8E11FD72EEF27857F31BA635EBDECDE4ACB6303FE08D673B02A3C299440
DDF54934BD36DD2B64506B7584C1F74ED23ECBE4F972A0E606E69486B3",true,new
CryptoPP::HexDecoder);
        CryptoPP::RSAES_PKCS1v15_Decryptor desenc(randPool,512,
CryptoPP::Integer("h99CEB83B184A0CA0F9FFF26792F44CBF1532799BABB18C9F1E998792
3AAEF142BD30C0F5E0464051A4E860E29B06EA9CD7AEDB5E1454CD06793EB355B2838293"));
        
        /*CryptoPP::HexDecoder hexDecoder;
        hexDecoder.Put((byte *)Entrada.GetBuffer(), strlen(Entrada));
        hexDecoder.MessageEnd();
        CryptoPP::SecByteBlock
buf(desenc.CiphertextLength(strlen(Entrada)));
        hexDecoder.Get(buf, desenc.CiphertextLength(strlen(Entrada)));*/
        
        char *outstr = new
char[desenc.MaxPlaintextLength(strlen(Entrada))+1];

        CryptoPP::DecodingResult r = desenc.Decrypt(randPool,(byte
*)Entrada.GetBuffer(),Entrada.GetLength(),(byte *)outstr);
        
        outstr[r.messageLength] = 0;
        CString csRet;
        csRet.SetString(outstr.c_str(),outstr.size());
        return csRet;
}

Hope that helps

----------------------------------------------------------------------------
-----------------------------------------

Hi I'm quite a newbie using Crypto++.

I haven't fully understood how Crypto++ works out, how it is designed,
I just read the user guide and a bit of
reference and figured out how to encrypt/decrypt using SOSEMANUK, AES.
The problem is, making use of public key algorithms such as RSA seems
quite different.
The user guide shows me how to create keys, write it to a file, read
it, perform encryption/decryption.
In my case, I don't have to do all these file accesses, all I need to
do is create a key, encrypt/decrypt something.
Encrypting/Decrypting a text directly with the keys generated didn't
work out for me, maybe I've been doing
something wrong and it's just because I'm short of knowledge.

Can anyone give me a short sample of using Crypto::RSA without doing
any file accesses?
I would really appreciate it. Thanks in advance.



        

        
                
__________________________________________________ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [EMAIL PROTECTED]
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to