Encrpytion routine - embedded nulls in BSTR

  • Thread starter Thread starter mtay
  • Start date Start date
M

mtay

I’m currently working on a VC++ 2005 dll used for encrypting and decrypting
passwords to be stored in an LDAP.

This dll needs to be called by a VB6 application, so I find myself limited
(I think) to using BSTR as the return value.

The encryption routine returns a char array which frequently contains null
characters. When I convert to a BSTR I’m losing all characters after the null.

I’ve tried SysAllocStringByteLen to control the length of the BSTR
(converting the char array to LPSTR beforehand) but the BSTR bears no
resemblance to the characters I started with.

I’ve also tried SysAllocStringLen, but I’m unable to convert to the right
data type without losing the characters after the null.

Can anyone suggest a way around this? I’ve thrown everything in my limited
knowledge at it.

If I changed my end component to VB.net, would this make a difference? Can I
use data types close to the VC++ ones?
 
mtay said:
I’m currently working on a VC++ 2005 dll used for encrypting and
decrypting
passwords to be stored in an LDAP.

This dll needs to be called by a VB6 application, so I find myself limited
(I think) to using BSTR as the return value.

The encryption routine returns a char array which frequently contains null
characters. When I convert to a BSTR I’m losing all characters after the
null.

You may want to try returning a simple array of chars, using SAFEARRAY
instead of BSTR.

HTH,
Giovanni
 
mtay said:
I’m currently working on a VC++ 2005 dll used for encrypting and
decrypting
passwords to be stored in an LDAP.

This dll needs to be called by a VB6 application, so I find myself limited
(I think) to using BSTR as the return value.

The encryption routine returns a char array which frequently contains null
characters. When I convert to a BSTR I’m losing all characters after the
null.

You may want to try returning a simple array of chars, using SAFEARRAY
instead of BSTR.

HTH,
Giovanni
 
Giovanni said:
You may want to try returning a simple array of chars, using SAFEARRAY
instead of BSTR.

Or do some post-encryption encoding, such as BASE64 so that the results are
guaranteed to be simple text.

-cd
 
Giovanni said:
You may want to try returning a simple array of chars, using SAFEARRAY
instead of BSTR.

Or do some post-encryption encoding, such as BASE64 so that the results are
guaranteed to be simple text.

-cd
 
Back
Top