fivewin/Harbour encrypt decrypt function in c#

fivewin/Harbour encrypt decrypt function in c#

Postby lorenzoazz » Tue Oct 13, 2015 9:08 am

Hello,
I have a program written in fivewin nad harbour that encrypt some text in memo fields.

Now i try to incorporate same dbf and fpt in Visualstudio 2013.
I get the dbf and the encrypted memo but i cannot decryt without the decrypt / encrypt functions.
I tried to find the functions source to transalte them in c# but with no luck. It seems they are "only" compiled in .lib file.

Can anyone tell me where or how to get the source?
Or how to include the fivewin .lib in visualstudio project, if possible?

ANOTHER OPTION COULD BE TO CREATE A DLL WITH THE TWO FUNCTION referenced?
Is this possible, and, if yes, how?

Thanks
Lorenzo
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am

Re: fivewin/Harbour encrypt decrypt function in c#

Postby Antonio Linares » Tue Oct 13, 2015 9:29 am

Lorenzo,

We can email you its source code. We don't include it in FWH sources for security reasons.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: fivewin/Harbour encrypt decrypt function in c#

Postby lorenzoazz » Thu Oct 15, 2015 7:59 pm

Thanks Antonio you are very great!
but it is very difficult to translate a bitwise in c# :)

do you think it is better to make a dll or something more easy to do?
Lorenzo
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am

Re: fivewin/Harbour encrypt decrypt function in c#

Postby Antonio Linares » Fri Oct 16, 2015 7:24 am

Lorenzo,

You can do bitwise dividing by 2 or multiplying by 2 :-)

In example:

01110111 --> 119

Divided by 2:

111011

Multiplied by 2:

11101110
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: fivewin/Harbour encrypt decrypt function in c#

Postby lorenzoazz » Sun Oct 25, 2015 1:35 pm

Thank you Antonio, i tried to translate in c# and then i decided to use another way: to call my program from c# ( from a web form) then usa a text file to transfer data from fivewin engine to html using a file.
This works great from Visualstudio 2013 IDE
BUT ( there is always a BUT in Windows 8.1 and 10) :shock:
when deployed as a normal c# web app, calling the exe means to call a process in a different "ambient".
So the exe run but in an infinite loop doing nothing visible.

I search on internet for a solution (many), with no luck.

Now i am thinking for a "great" solution if possible; that is, using a "Windows Service" written in harbour/fivewin, able to run my
old functions or program(exe) and pass them arguments.

Did you already make this wheel? :P

Lorenzo
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am

Re: fivewin/Harbour encrypt decrypt function in c#

Postby rhlawek » Sun Oct 25, 2015 2:39 pm

Lorenzo,

I'm not sure if you are using harbour of xharbour. If harbour you might want to have a look at contribs\hbwin. The olesrv*.prg present there are both easy to understand and useful, as is the service.prg. Although I've stopped using it now, for a number of years I used just such an harbour OLE server to expose hbnetio to be called and used from xharbour programs (VxH) where I needed this functionality. The contrib/hbwin folder contains examples to call from javascript, .vbs.

Just a suggestion.

Robb
User avatar
rhlawek
 
Posts: 193
Joined: Sun Jul 22, 2012 7:01 pm

Re: fivewin/Harbour encrypt decrypt function in c#

Postby Antonio Linares » Sun Oct 25, 2015 11:54 pm

Lorenzo,

You can create a Windows DLL and use it from your .NET app.

Thats what I did in FiveNet:

https://code.google.com/p/fivenet/wiki/architecture
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: fivewin/Harbour encrypt decrypt function in c#

Postby lorenzoazz » Fri Oct 30, 2015 8:51 am

Actually i found that, it is possible to run an xHarbour/fivewin exe from c# net with no problems, if i do not define any Window ,
that is, running a dos executable, without desktop implications.

Now i would try your suggestion that seems VERY interesting.
In effect this would eliminate the "problem" to read the code, without obfuscation, that is a more secure one.


Thanks Antonio
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am

Re: fivewin/Harbour encrypt decrypt function in c#

Postby lorenzoazz » Sat Nov 07, 2015 8:20 am

Ok Antonio, many of us made thousands of lines of marvellous code with fivewin, trhrough decades :shock: , thanks to your tremendous work.
Now, all is web and html and .net, so, what an incredible step over, would be to use our old but overtested fivewin algorythm in .Net !

Now, i was able to use all my old fivewin code from visualstudio .net project, by simply calling (running) my exe without activate ANY window.
That is, no need to change my code; simply i do not Activate any window.
This way i can maintain reference to main ownd and owndclient window without changing a line of code
and write the output i need, into a file that i can then read from c# .net.

I then tried to look at your fivenet project that seems to allow to run a windowed exe from net.

So, i registered with
c:\Windows\Microsoft.NET\Framework\v2.0.50727\regasm fivenet.dll /tlb
and also with
C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm fivenet.dll /tlb

then from my c# net project i tried to run one of your exe (tutor01.exe) with



scriptProc.StartInfo.FileName = @"tutor01.exe";
scriptProc.Start();
scriptProc.WaitForExit();

but i have no message prompt and no error from .net

Sorry if i post here referring to fivenet, but as i understand better the architecture i will post in fivenet forum.

Thanks :roll:
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am

Re: fivewin/Harbour encrypt decrypt function in c#

Postby Antonio Linares » Sat Nov 07, 2015 11:59 am

Lorenzo,

If you directly run tutor01.exe, does it work ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: fivewin/Harbour encrypt decrypt function in c#

Postby Antonio Linares » Sat Nov 07, 2015 12:05 pm

I just realized why it is not working from your C# app:

I use GetModuleFileName( NULL, ... ) to access the root app (tutor01.exe) and it you start tutor01.exe
from your C# app, then tutor01.exe is not the root app anymore :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: fivewin/Harbour encrypt decrypt function in c#

Postby Antonio Linares » Sat Nov 07, 2015 12:08 pm

We could replace:

GetModuleFileName( NULL, ... )

with:

GetModuleFileName( GetModuleHandle( "tutor01.exe" ), ... )

and that should solve the problem :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: fivewin/Harbour encrypt decrypt function in c#

Postby lorenzoazz » Sat Nov 07, 2015 4:32 pm

Antonio,
answering to you first question, if i can run tutor01.exe directly (by double-clicking on it):
Not, or anyway i cannot see any messagebox appearing, nor any error!

And, by the way, how can i run tutor01.exe from c# web application if not by running it as an externalk process?
There is another o better way?

thanks

Lorenzo
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am

Re: fivewin/Harbour encrypt decrypt function in c#

Postby Antonio Linares » Sat Nov 07, 2015 10:14 pm

tutor01.exe should work fine on your pc.

I don't think that you can use Windows GUI when executing an EXE from web .NET code

Is it possible to do it with C# ? Can you build a tutor01.exe with C# and call it from your web code ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: fivewin/Harbour encrypt decrypt function in c#

Postby lorenzoazz » Tue Nov 10, 2015 10:13 am

No, Antonio,
tutor01.exe (that should be ....a simple message to show)
Code: Select all  Expand view
/ FiveNet - simple message

function Main()

   MsgInfo( "Welcome to FiveNet" )
   
return nil


does nothinìg if i run directly on my windows 10 pc. It runs and exit without showing any message.
---------------------------------------------------------------------------------------------------------------------

Anyway my intent was to be able to run fivewin window's exe on the web from a web c# .net site.
Seems that this is impossible (something is possible with "net remoting" but it is not what i want.

Instead, as i can safely run my fivewin executable, (without Activating any window from it), i can comunicate with the exe through xml or txt files.
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 11 guests

cron