Skip to main content
We're using U9.2 - before $encode/$decode were implemented & we'd like to decode base64 we're receiving.

Tried to use the cryptBinaryToStringA operation in the crypt32.dll but not sure how to define the parameters: a couple are 'pointers'.
Presumably we also have to specify the dll in the asn file?

Can anybody help?

Crypt32.dll Wincrypt.h
C++ function to convert an array of bytes into a formatted string.
If the function succeeds, the function returns nonzero (TRUE).
If the function fails, it returns zero (FALSE).

BOOL CryptBinaryToStringA(
[in] const BYTE *pbBinary, Pointer to the array of bytes to be converted into a string.
[in] DWORD cbBinary, Number of elements in the pbBinary array.
[in] DWORD dwFlags, Format of the resulting formatted string.
[out, optional] LPSTR pszString,
[in, out] DWORD *pcchString);

------------------------------
R W
Hargreaves Lansdown Asset Mgmt
Bristol GB
------------------------------
We're using U9.2 - before $encode/$decode were implemented & we'd like to decode base64 we're receiving.

Tried to use the cryptBinaryToStringA operation in the crypt32.dll but not sure how to define the parameters: a couple are 'pointers'.
Presumably we also have to specify the dll in the asn file?

Can anybody help?

Crypt32.dll Wincrypt.h
C++ function to convert an array of bytes into a formatted string.
If the function succeeds, the function returns nonzero (TRUE).
If the function fails, it returns zero (FALSE).

BOOL CryptBinaryToStringA(
[in] const BYTE *pbBinary, Pointer to the array of bytes to be converted into a string.
[in] DWORD cbBinary, Number of elements in the pbBinary array.
[in] DWORD dwFlags, Format of the resulting formatted string.
[out, optional] LPSTR pszString,
[in, out] DWORD *pcchString);

------------------------------
R W
Hargreaves Lansdown Asset Mgmt
Bristol GB
------------------------------
Are sure that the CryptBinaryToStringA function is decoding data? If I read it correctly then it is encoding or converting data to a formatted string (like e.g. Base64). I think you would need CryptStringToBinaryA to decode Base64.

Anyway, looking at the interface definition I don't think that there is a straight forward way to call the mentioned function with a C Call-Out signature. I have never tried to call a parameter that is a pointer to an array of bytes. I know there is a way to handle a pointer to a string, but that is different (AFAIK).

But why not use a default Windows command line tool that can do this, and call it from Uniface (with e.g. the Operating System Commands signature)? If I understand it correctly then the Certutil.exe can decode Base64 data. See (e.g.):
I hope this helps.

------------------------------
Daniel Iseli
Principal Technical Support Engineer
Uniface Services
Rocket Software, Switzerland
------------------------------
Are sure that the CryptBinaryToStringA function is decoding data? If I read it correctly then it is encoding or converting data to a formatted string (like e.g. Base64). I think you would need CryptStringToBinaryA to decode Base64.

Anyway, looking at the interface definition I don't think that there is a straight forward way to call the mentioned function with a C Call-Out signature. I have never tried to call a parameter that is a pointer to an array of bytes. I know there is a way to handle a pointer to a string, but that is different (AFAIK).

But why not use a default Windows command line tool that can do this, and call it from Uniface (with e.g. the Operating System Commands signature)? If I understand it correctly then the Certutil.exe can decode Base64 data. See (e.g.):
I hope this helps.

------------------------------
Daniel Iseli
Principal Technical Support Engineer
Uniface Services
Rocket Software, Switzerland
------------------------------
Nope, I wasn't sure. 
Gave up with trying a callout to WINAPI.

Peter Lammersma suggested trying certUtil - and it worked!

Just noticed that another component uses xmlsave/xmlload to perform the conversion...but didn't try it for the new instance as certUtil works fine.

------------------------------
R W
Hargreaves Lansdown Asset Mgmt
Bristol GB
------------------------------