Prev: And now the news from VODC Germany
Next: JPG to BMP
From: Lennart Björk on 13 Nov 2006 10:52 Ronny, > Another version (www.cryptosys.net) ? Here it is called DICRYPTOSYS.DLL ... < I was there but I failed to find a DICRYPTOSYS.DLL Lennart Bj?rk
From: Ronny Michiels on 13 Nov 2006 11:07 Lennart, It appeared when downloading and installing the 'personal version' installation EXE (600 kB). http://www.cryptosys.net/download_p.html Ronny. Lennart Bj?rk wrote: > Ronny, > > > > Another version (www.cryptosys.net) ? > Here it is called DICRYPTOSYS.DLL ... > < > > I was there but I failed to find a DICRYPTOSYS.DLL > > Lennart Bj?rk
From: dlzc on 15 Nov 2006 14:43 Dear Lennart Björk: Lennart Björk wrote: > Malcolm Gray, > > > > Do you have a C prototype for the function > < > > The manual of the function does not say much about C, but there is > > > /* CRC-32 PROTOTYPE */ > long _stdcall cHEX_CRC32(char *output, unsigned char *input, long in_len); > > Note the lower-case letter 'c' preceding each name here to differentiate > from the functions in the Visual Basic interface. We have used the ANSI > standard char* and unsigned char* types here, but could have used the > Windows LPSTR and LPBYTE instead. I notice in your code: <QUOTE> Example Dim sInput As String Dim sOutput As String ' Take a string we want to check sInput = "123456789" ' Calculate CRC-32 checksum sOutput = HEX_CRC32(sInput) Debug.Print sOutput <END QUOTE> .... that you did not supply the length of the string (as an integer) as the second parameter, as the c-prototype seems to require. Are you sure that VO will know to send this information to your DLL, if you don't supply it? David A. Smith
From: Robert van der Hulst on 15 Nov 2006 15:24 Hi Lennart, On Mon, 13 Nov 2006, at 15:19:57 [GMT GMT] (which was 16:19 where I live) you wrote about: 'CRC32' > The manual of the function does not say much about C, but there is > /* CRC-32 PROTOTYPE */ > long _stdcall cHEX_CRC32(char *output, unsigned char *input, long in_len); > Note the lower-case letter 'c' preceding each name here to differentiate > from the functions in the Visual Basic interface. We have used the ANSI > standard char* and unsigned char* types here, but could have used the > Windows LPSTR and LPBYTE instead. Your Visual Basic example uses the data type 'String'. This datatype is also known as BString (Basic String) . It uses a special string header that holds the length of the input string (just like VO does). That is why you don't need to pass the source length. To allocate such as string you need to use the SysAllocString() function (from the Windows API). To free a string allocated using SysAllocString() you use SysFreeString(). I suggest you either use the C string prototype or convert the VO strings to Bstrings. Function MyCrc32(cInput as String) as String LOCAL pInput, pOutPut as PTR LOCAL nLen as DWORD LOCAL cOutPut as String nLen := Slen(cInPut) pInput := SysAllocString(nLen) if pInput == NULL_PTR // Eror else Memcopy(pInput, PTR(_CAST,cInPut), nLen) endif pOutPut := HEX_CRC32(pInput) if (pOutPut != NULL_PTR) cOutPut := Mem2String(pOutPut, 8) SysFreeString(pOutPut) endif SysFreeString(pIntPut) return cOutPut It is possible that you may need to convert Ansi strings to Unicode first. In that case you can use String2W() and W2String() (both in module Util from the System Library) to convert the string to and from a Unicode Bstring. Using the C function is much easier: Function MyCrc32(cInput as String) as String LOCAL pOutPut as PTR LOCAL nLen as DWORD LOCAL cOutPut as String nLen := Slen(cInPut) pOutPut := MemAlloc(8) cHEX_CRC32(pOutPut, Cast2Psz(cInput), nLen) cOutPut := Mem2String(pOutPut,8) MemFree(pOutPut) return cOutPut -- Robert van der Hulst AKA Mr. Data Vo2Jet & Vo2Ado Support VO Development Team www.heliks.nl
From: Lennart Björk on 16 Nov 2006 10:00
This was a real lesson! I do thank everybody who has helped me. First I tried all these hints to use psz instead of strings. It was a good try with many variations. They all had one characteristic in common. I was kicked out with an enlightning message about 5333. The hint from Ronny Michiels helped me through. With a more recent version of the dll I made it. The code: _dll function CRC_String(pszInput as psz, nOptions as longint) as longint pascal:diCryptoSys.CRC_String method CRC_Test() class Shell local pszInput as psz local liOutput as longint local sOutput as string pszInput := String2Psz("123456789") liOutput := CRC_String(pszInput,0) // Zero as nOptions ??? sOutput := AsHexString(liOutput) // Now I have a correct result in sOutput to show return However, the dll diCryptoSys.DLL is not free. So if I want to save my money I have to be a bit more obstinate with the original DLL. And with the assistance from Robert van der Hulst I made it on the very first try. His hint that 'Using the C function is much easier' made me rewrite the method above like method CRC_Test() class Shell local cInput as string local pOutPut as ptr local nLen as dword local cOutPut as string cInput := "123456789" nLen := SLen(cInPut) pOutPut := MemAlloc(nLen) cHEX_CRC32(pOutPut, Cast2Psz(cInput), nLen) cOutPut := Mem2String(pOutPut,nLen) MemFree(pOutPut) // Now I have a correct result in cOutput to show return Robert left some coding for me. What about the _dll-function? I tested with _dll function cHEX_CRC32(pOutput as ptr, pszInput as psz, dwLen as dword) as ptr pascal:diCrEnc.cHEX_CRC32 and it seems to work. Regards Lennart Bj?rk |