FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to make encrypt()/decrypt() produce same result in 16/32
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Thu Mar 22, 2007 03:35 AM

How to enable encrypt()/decrypt() to produce the same result in 16 and 32 bits version? So far I noticed a 16-bit decrypt() can't correctly decrypt a string encrypted by a 32-bit encrypt().

Any help is much appreciated as it's quite urgent.

TIA.

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Thu Mar 22, 2007 06:23 AM

Hua,

We are going to review this issue as soon as possible.

We are actually at Holland providing a FWPPC seminar but today we will look for some free time to review it

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Thu Mar 22, 2007 08:56 AM

Thanks Antonio. Appreciate it :)

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Sun Mar 25, 2007 09:40 PM

Hua,

We have tested it in both 16 and 32 bits and the results are the same.

Could you please provide a sample where the encrypted result is different ? thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Wed Apr 04, 2007 09:47 AM
Sorry for the late reply Antonio. Got to finish other stuffs that were due first. A brief description about the following samples. There would be 2 exe involved. The 32-bit exe would be calling the 16-bit exe.

This is the code for the 32-bit exe. (FWH2.8+xHarbour 0.99.61)
#include "FiveWin.ch"

function Main()

   local oDlg, oIco, cId := "SUPERVISOR"

   DEFINE ICON oIco FILE "..\icons\fivewin.ico"

   DEFINE DIALOG oDlg TITLE "I am a DialogBox" COLOR "W+/B" ;
      ICON oIco


   @ 3, 5 BUTTON "Run module" SIZE 40, 12 ;
      ACTION winexec("exe16.exe "+encrypt(trim(cId))  )


   ACTIVATE DIALOG oDlg CENTERED

return nil


And this is the code for the 16-bit exe. (FW2.3+Clipper 5.2)
#include "fivewin.ch"

function main16(cID)

  default cId := ""
  msginfo(decrypt(trim(cID)))

return nil


The resulting string is not SUPERVISOR as expected.
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Wed Apr 04, 2007 11:35 AM

Hua,

Thats risky: the encrypted result may contain embedded zeroes that the application initialization may not properly parse.

Better write the encrypted text to a file and read that file from the 16 bits EXE

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Wed Apr 04, 2007 03:24 PM

Hua,

>Better write the encrypted text to a file and read that file from the 16 bits EXE

If you do this, don't forget to securely erase the file after reading it. I don't mean to just delete it, but to write dummy data to it multiple times before deleting it.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Thu Apr 05, 2007 02:31 AM

Antonio, James, thanks for the feedback and input. It never occur to me that passing encrypted string as I was doing could be problematic as the string length stays the same in exe32 and exe16.

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Thu Apr 05, 2007 03:59 PM

Hua,

I don't know if this will work, but you could try:

@ 3, 5 BUTTON "Run module" SIZE 40, 12 ;
ACTION winexec([exe16.exe ]+["]+encrypt(trim(cId))+["] )

Enclosing the passed parameter in quotes may fix any problems with spaces in cID.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Fri Apr 06, 2007 01:11 AM
Thanks for the idea James. I just find it odd that if both the above samples are compiled in 16-bit I do get the expected string i.e. SUPERVISOR
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 172
Joined: Fri Oct 07, 2005 01:29 PM
Passing encrypted strings
Posted: Fri Apr 06, 2007 05:36 AM
Hi,

Another trick I use where high (>127) ascii and low(<32) can be tricky is to mime encode the strings

   @ 3, 5 BUTTON "Run module" SIZE 40, 12 ;
      ACTION winexec("exe16.exe "+cmimeenc(encrypt(trim(cId)))  )


and

msginfo(trim(decrypt(cmimedec(cId))))
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Fri Apr 06, 2007 06:45 AM

Hua,

>Thanks for the idea James. I just find it odd that if both the above samples are compiled in 16-bit I do get the expected string i.e. SUPERVISOR.

Granted that does seem odd. Are you using the same versions of FW and FWH? Perhaps there was a change in the versions that is causing the problem rather than 16bit vs 32bit.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Fri Apr 06, 2007 08:07 AM

James,

There have not been changes in functions Encrypt() and Decrypt() source code. Its easy to check that their results are compatible, so Hua problem has to be something else. Maybe something related to calling 16 bits from 32 bits.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to make encrypt()/decrypt() produce same result in 16/32
Posted: Mon Apr 09, 2007 01:30 AM
James wrote:
@ 3, 5 BUTTON "Run module" SIZE 40, 12 ;
ACTION winexec([exe16.exe ]+["]+encrypt(trim(cId))+["] )


Unfortunately, the above didn't work James.

James wrote:
Granted that does seem odd. Are you using the same versions of FW and FWH? Perhaps there was a change in the versions that is causing the problem rather than 16bit vs 32bit.


No. I'm using FW2.3 and FWH2.8 respectively. I'm holding on to a time-tested principle, "if it ain't broken, don't fix it". :-) Hence my reluctance to touch anything that's working fine so I left my 16-bit programs with FW16. I doubt there was a change, if there was, a lot more people would've been affected.

AlexSchaft wrote:
Another trick I use where high (>127) ascii and low(<32) can be tricky is to mime encode the strings


Hey, that's a neat trick there Alex. I'll keep it in mind. I know it'd have never crossed my mind.
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion