string to _bstr_t conversion
From: Marco (tiodemo_at_hotmail.com)
Date: 02/04/04
- Next message: Klaus Bonadt: "No memory although more than 1GB free"
- Previous message: William DePalo [MVP VC++]: "Re: C versus C++ compiler optimization?"
- Messages sorted by: [ date ] [ thread ]
Date: 4 Feb 2004 10:34:29 -0800
Hi everybody,
I'm developing an application that reads a text file delimited with
fields. The application must verify a signature that is inserted in
one of the fields. In another field is the entire content of the
signed file in base 64.
I'm using the Capicom libraries to verify the signature. I decode the
content of the file and insert it into a type string. The signedData
object of Capicom needs to recive in the property content a type
_bstr_t.
My problem is how to convert my string into a _bstr_t. I have made
some test like this:
string str = base64decode(example variable);
_bstr_t bs = str.c_str();
I can't use The following code 'cause I need to use a variable instead
of plain text as the parameter of SysAllocString. This variable must
be the decoded message (str in the above example):
BSTR strFoo = SysAllocString(L"This is a test");
_bstr_t bstrFoo = strFoo;
SysFreeString(strFoo);
std::string sstrFoo = bstrFoo;
Can anybody help me, please? Is there any other way of convert this
kind of string for insert the decode message to a signedData object?
Can my problem be in loosing data 'cause the data is binary format
(the file is a pdf document)?
This is the code i'm using now:
CString m_ContenidoFactura; ---> the base64 encoded content of the pdf
CString m_FirmaFactura; ---> the base64 encoded signature
string sContenidoFactura = b64->decode ((string)m_ContenidoFactura);
CString csContenidoFactura(sContenidoFactura.c_str());
_bstr_t bsContenidoFactura(csContenidoFactura.AllocSysString());
_bstr_t bsSig = pISignedData->Verify
(m_FirmaFactura.AllocSysString(),true,CAPICOM_VERIFY_SIGNATURE_ONLY );
Thanks to all, any reply will be wellcomed.
Marco Antonio Tabasco.
- Next message: Klaus Bonadt: "No memory although more than 1GB free"
- Previous message: William DePalo [MVP VC++]: "Re: C versus C++ compiler optimization?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|