Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #6024
| From | "Francesco F." <francescangeli.f.remove@remove.gmail.com> |
|---|---|
| Newsgroups | comp.lang.clipper.visual-objects |
| Subject | Someone of you knows about CryptBinaryToString ? |
| Date | 2013-10-05 19:06 +0200 |
| Organization | albasani.net |
| Message-ID | <l2pgup$a3n$1@news.albasani.net> (permalink) |
I need help about a function in Crypto32.dll; I need to convert a
calculated MD5 in Hex form to MD% in base64 form, (22 chars, like
"xx4K6Mixq/dDUQORH2dLPQ==").
The ultimate goal is to send via WebService a file and its Hash in MD5
base64, as requested.
I'm struggling with CryptBinaryToString(), but it seems to be hard to me
to chew...
Basing on what found googleing for hours, I created a prototype:
_DLL FUNCTION CryptBinaryToString(pbBinary AS BYTE PTR, cbBinary AS
DWORD, dwFlags AS DWORD, pszString AS PSZ, pcchString AS PTR) AS DWORD
PASCAL:crypt32.CryptBinaryToStringA
and then, stealing up and down in NG I wrote this pearl: 8-))
--------------------------------------------------
FUNCTION BASE64(InputStr AS STRING) AS STRING
// InputStr = "C71E0AE8C8B1ABF7435103911F674B3D", an MD5 in Hex format
LOCAL cOutput AS STRING
LOCAL nbuffer AS DWORD
LOCAL nSize AS DWORD
LOCAL ptrByte AS BYTE PTR
LOCAL ptrWord AS WORD PTR
LOCAL waw AS DWORD
nSize := Len(InputStr)
ptrByte := MemAlloc(nSize)
FOR waw := 1 UPTO nSize
ptrByte[waw] := BYTE(_CAST, SubStr(InputStr, waw, 1))
NEXT
cOutput := PSZ(Space((nsize / 2) + 1))
nbuffer := 0
CryptBinaryToString(ptrByte, nSize, CRYPT_STRING_BASE64, cOutput, @nbuffer)
? nbuffer // here returns 0
MemFree(ptrByte)
RETURN cOutput
--------------------------------------------------
My doubt is about that nbuffer.
MS$ states:
BOOL WINAPI CryptBinaryToString(
_In_ const BYTE* pbBinary,
_In_ DWORD cbBinary,
_In_ DWORD dwFlags,
_Out_opt_ LPTSTR pszString,
_Inout_ DWORD* pcchString
)
and looks like DWORD* is a PTR.
Where am I wrong?
TIA for any help,
Francesco
Back to comp.lang.clipper.visual-objects | Previous | Next — Next in thread | Find similar | Unroll thread
Someone of you knows about CryptBinaryToString ? "Francesco F." <francescangeli.f.remove@remove.gmail.com> - 2013-10-05 19:06 +0200
Re: Someone of you knows about CryptBinaryToString ? Sherlock <sherlock@sherlock.com.au> - 2013-10-06 03:57 -0700
Re: Someone of you knows about CryptBinaryToString ? "Francesco F." <francescangeli.f.remove@remove.gmail.com> - 2013-10-06 14:50 +0200
Re: Someone of you knows about CryptBinaryToString ? Gustavo Biasone <rosario.soft@gmail.com> - 2013-10-14 09:35 -0700
Re: Someone of you knows about CryptBinaryToString ? "Francesco F." <francescangeli.f.remove@remove.gmail.com> - 2013-10-15 08:33 +0200
csiph-web