Hello! When I try to use the MD5 algorithm with the wwEncryption.ComputeHash method I'm receiving the message bellow. Is there a way to use the MD5 algorithm with that class ?
Thanks, Marcelo
This works for me:
CLEAR
DO wwApi
DO wwEncryption
lcOriginal = "Hello World"
o = CREATEOBJECT("wwEncryption")
? o.ComputeHash(lcOriginal,"MD5")
*** utility function in wwApi (uses Windows Encryption APIs)
? STRCONV(HashMd5(lcOriginal),13)
They produce the same thing, although both of them use completely different encryption engines in Windows.
+++ Rick ---
Hi Marcelo,
I can get it to work with Rick's sample as well. Check if there is not an extraneous character after the "MD5" as I get an error raised even if there is a space beyond the "MD5".
Albert
Didn't work even copy/pasting that exact code It stops at that line:
Can you output the values of all the passed parameters at this point (I think it is the 2nd parameter anyhow, lcMethod).
Albert
Hello Albert! Here they are:
Parameters look correct to me. What parameters are you passing to .ComputeHash() itself? Does it help to not pass lvSaltHash?
Albert
I tried both. With and without lvSaltHash. Both don't work. Could it be the DLL version ?
With lvSaltHash lcOriginal = "Hello World" o = CREATEOBJECT("wwEncryption") MessageBox( o.ComputeHash(lcOriginal,"MD5", "") )
Without lvSaltHash lcOriginal = "Hello World" o = CREATEOBJECT("wwEncryption") MessageBox( o.ComputeHash(lcOriginal,"MD5") )
I guess Rick will have to jump in. You might as well proactively give him your dll version, and perhaps .net version etc. I am out of ideas. Albert
Not sure... As Albert pointed out, make sure you're using a proper set of matched PRG and DLL versions and a recent version. There were some updates recently.
However if both of those functions are failing (are they?) then there's likely some system problem as the two methods use two completely different technologies for the hash creation (1 is .NET, the other is the Win32 Crypto APIs). If both of those fail it has something to do with Windows. What version of Windows? XP or Vista perhaps?
I'm using a Windows10 fully updated.
The dll version I have (just bought) is this:
And I have those .Net versions instaled:
I use VFP9 SP2
You should run:
loBridge = CREATE("wwDotnetBridge")
? loBridge.GetDotnetVersion()
this will show you versions of wwDotnetBridge and Windows that is in use plus the location of files to make sure you're using what you think you are.
The important thing is to match the PRG to the DLL so that the signatures match.
+++ Rick ---
On the prg I have cClrVersion = "v4.0.30319"
Hmmm... then I don't know.
Looks like you're on Windows 11 like me?
I can't think of why the Crypto APIs wouldn't work. Can you share your code? The code you showed before works for me...
+++ Rick ---
My test code is the following:
D:\Desenv\LpFrame\WestWind -> dll's are here D:\Desenv\LpFrame\WestWind\Classes -> prg's are Here
Set Talk Off
Set Default To D:\Desenv Set Path To D:\DESENV\LPFRAME\CLASSES,D:\DESENV\LPFRAME\FORMS,D:\DESENV\LPFRAME\PRGS,D:\DESENV\LPFRAME\REPORTS,; D:\Desenv\LpFrame\WestWind,D:\Desenv\LpFrame\WestWind\Classes,
Do wwApi
Do wwEncryption
Do wwHttp
Do wwJsonSerializer
Do wwCollections
Do wwDynamic
Do wwSmtp
oEncryption = CREATEOBJECT("wwEncryption") MessageBox( oEncryption.ComputeHash("Hello World!!", "MD5") )
I'm not sure...
But here's what I get:
Maybe just for kicks - download West Wind Client Tools (Shareware is fine) which has v7.23 of the DLL and see if that DLL makes a difference (it shouldn't but that's what I'm using here).
+++ Rick ---
Using the v7.23 of the Dll it worked!!! Thank you!
Hmmm... good. I wonder though why that is. I know when Web Connection 7.22 was originally shipped there were a few quick bug fixes made, which included a couple of fixes for wwEncryption. You might have been in that short window when the buggy version was around before I updated it.
It should be working correctly in the next update for Web Connection and it's fixed in the current release of Web Connection as well.
+++ Rick --