问题
i am doing RSA encryption
i want to convert reference of public key class to string so that i can pass to server
//declaration
const CRSAPrivateKey &iRSAPrivateKey =iRSAKeyPair->PrivateKey();
const CRSAPublicKey &iRSAPublicKey =iRSAKeyPair->PublicKey() ;
i have convert &iRSAPublicKey
into TBuf
i tried lot but fails to convert
plz help me out from situation
thanks in advance
回答1:
If you're using CRSAPublicKey, you probably downloaded the Symbian cryptography library and its documentation from http://developer.symbian.com/main/tools_and_sdks/developer_tools/supported/crypto_api/index.jsp
Admitedly, the documentation isn't explicit but I would venture that you can just send the modulus and exponent components to any other RSA engine in order to reconstitute the public key:
HBufC8* localModulusBuffer = iRSAPublicKey.N().BufferLC();
HBufC8* localExponentBuffer = iRSAPublicKey.E().BufferLC();
Then simply copy the 2 HBufC8 into a TBuf if you really need it.
Just remember that methods with a trailing "C" leave what they return on the cleanup stack.
来源:https://stackoverflow.com/questions/909035/regarding-conversion-from-reference-to-string