FoxPro Programming
MD5 Hash not working
Gravatar is a globally recognized avatar based on your email address. MD5 Hash not working
  Marcelo Pacetta
  All
  Sep 21, 2021 @ 07:26am

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

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Rick Strahl
  Marcelo Pacetta
  Sep 21, 2021 @ 11:46am

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 ---

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Albert Gostick
  Marcelo Pacetta
  Sep 22, 2021 @ 12:38pm

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

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Marcelo Pacetta
  Albert Gostick
  Sep 22, 2021 @ 02:34pm

Didn't work even copy/pasting that exact code It stops at that line:

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Albert Gostick
  Marcelo Pacetta
  Sep 22, 2021 @ 03:34pm

Can you output the values of all the passed parameters at this point (I think it is the 2nd parameter anyhow, lcMethod).

Albert

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Marcelo Pacetta
  Albert Gostick
  Sep 23, 2021 @ 03:49am

Hello Albert! Here they are:

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Albert Gostick
  Marcelo Pacetta
  Sep 23, 2021 @ 07:59am

Parameters look correct to me. What parameters are you passing to .ComputeHash() itself? Does it help to not pass lvSaltHash?

Albert

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Marcelo Pacetta
  Albert Gostick
  Sep 23, 2021 @ 11:03am

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") )

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Albert Gostick
  Marcelo Pacetta
  Sep 23, 2021 @ 11:37am

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

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Rick Strahl
  Marcelo Pacetta
  Sep 23, 2021 @ 12:28pm

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?

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Marcelo Pacetta
  Rick Strahl
  Sep 23, 2021 @ 01:15pm

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

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Rick Strahl
  Marcelo Pacetta
  Sep 23, 2021 @ 01:17pm

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 ---

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Marcelo Pacetta
  Rick Strahl
  Sep 23, 2021 @ 01:31pm

On the prg I have cClrVersion = "v4.0.30319"

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Rick Strahl
  Marcelo Pacetta
  Sep 23, 2021 @ 01:36pm

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 ---

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Marcelo Pacetta
  Rick Strahl
  Sep 23, 2021 @ 02:08pm

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") )

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Rick Strahl
  Marcelo Pacetta
  Sep 23, 2021 @ 02:56pm

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 ---

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Marcelo Pacetta
  Rick Strahl
  Sep 23, 2021 @ 03:18pm

Using the v7.23 of the Dll it worked!!! Thank you!

Gravatar is a globally recognized avatar based on your email address. re: MD5 Hash not working
  Rick Strahl
  Marcelo Pacetta
  Sep 23, 2021 @ 03:31pm

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 --

© 1996-2024