Base64,MD5,Crypt,SSL with Basic4PPC..?

TWELVE

Active Member
Licensed User
Hello,

apparently Basic4PPC does not provide support for Base64,MD5 and Crypt( the linux Crypt, 56Bit DES with SALT) and - of course - SSL.


Is there a library known that does support all or at least one these functions i could use together with Basic4PPC...?

Does anyone have already a piece of code which is implementing all or one these functions OR is aware of how these functions work/ be calculated and can give some help in implementing such function in B4P code..?

Base64 is probably the easiest one i guess.

What about HTTPS..? AFAIK the WM Internet Explorer is capable of https.Would it be possible to use the Windows Library to get this functionality into B4P..?


kind regards

TWELVE
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Here's Base64 written in B4PPC (.NET doesn't provide this) stripped from one of my apps. .NET does provide MD5 and DES, I'll look at knocking up a library to do at least MD5. I'm not sure how standardized the Linux Crypt function is, if you have some password/encrypted text pair examples I could have a look at it.

About Https I have no idea as it it not part of my skill-set.

EDIT:- While exploring I've just found out that .NET does in fact provide Base64 but it is implemented in a dark obscure corner that I have never visited as static methods of the System.Convert class. Also, for some reason, the VS docs have no reference to Base64 as a topic! Anyway I've done it in B4PPC now.
 

Attachments

  • Base64.sbp
    2.4 KB · Views: 397
Last edited:

agraham

Expert
Licensed User
Longtime User
Last edited:

Elrick

Member
Licensed User
No problem agraham - i just couldn't look how you do the same again and again :) And thank you again for this very useful library!
 

LineCutter

Active Member
Licensed User
Longtime User
You could have left him to it, it would only have taken 45 minutes to recreate the MD5 library!
:sign0103: :sign0188:
 

Elrick

Member
Licensed User
No i couldn't! Just imagine how many powerful libraries could he create for this 45 minutes!:D
 

TWELVE

Active Member
Licensed User
Thanks Guys for the quick replies..!

So..no C / Linux Programmers here at all...? :))) Crypt is a standard unix encryption function...see this link:

http://en.wikipedia.org/wiki/Crypt_(Unix)


I wouldn't say Crypt is that secure, but i've to work with a linux/perl guy who loves it to rely on these old-fashioned stuff..:)))

@agraham: thanks again for the libs and code pieces you contribute.I will have a look at it and report how it works.

Another question: how can i use the .net lib functions in B4P...? The same style i add functions from the libraries delivered together with B4P...?

cheers

TWELVE
 

agraham

Expert
Licensed User
Longtime User
Crypt is a standard unix encryption function...see this link:
It may be standard but where is the algorithm?

Another question: how can i use the .net lib functions in B4P
A lib is a C not really a .NET concept. I think you mean how can you access the classes and methods of the Common Language Runtime. The answer, as far as Basic4PPC is concerned, is that you write a library. Most B4PPC libraries are shallow wrappers for calls to facilities offered by the CLR. One such is my new CryptoEx library http://www.b4x.com/forum/showthread.php?p=11986 which implements MD5 and DES.
 

TWELVE

Active Member
Licensed User
It may be standard but where is the algorithm?

Will have a look and tell ya..;-)


A lib is a C not really a .NET concept. I think you mean how can you access the classes and methods of the Common Language Runtime.

I'm afraid, you're right :)) I'm not so familiar with the .net stuff.In fact, i don't like to engage the user have a runtime installed just to run my program.
For the x86 Programming on Windows i like to use PureBasic.That's really neat and clean, creates very compact exe files, with no need to provide dlls or runtimes to the user.PureBasic can use so-called User-Libs, functions used ( and only these) from libraries are compiled into the exe file.

For a comparable application, PureBasic creates smaller exe files for a Windows x86 Box than B4P for PocketPC/WM does, while it still has twice the number of source lines with also more functionalities correspondingly.Not included the space .Net Runtime and additional libraries are consuming and PureBasic don't need.

So - from this point of view i can't see any advantage the .net is giving to me.Nevertheless for PocketPC/Wm i don't have a choice...looks like for these Devices one has to deal with the DotNet ( FreePascal/Lazarus apparently not ?).

To get back to your questions: yes i mean how to access classes and methods in .NET.


The answer, as far as Basic4PPC is concerned, is that you write a library. Most B4PPC libraries are shallow wrappers for calls to facilities offered by the CLR.


- Does this mean, a B4P Lib is always a wrapper lib for the CLR ( or something else..)...?

- Can't i use .NET classes without the use of such a wrapper lib..?

- is a B4P lib different from a usual windows dll...? Tried to involve a normal windows DLL, but this didn't work - got an error message ( something related to assemblies...;-) ).

One such is my new CryptoEx library http://www.b4x.com/forum/showthread.php?p=11986 which implements MD5 and DES.

I really like and appreciate your work..!!! I was waiting for such one...do you plan to expand that lib..? Unix Crypt would be a good expansion..:)))


cheers

TWELVE
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
The .Net runtime is already installed on all devices and most of the desktops so the runtime should not be a big issue.

Basic4ppc libraries are regular .Net libraries.
Some of the libraries are wrappers and some are not wrappers.
The door library allows you to use .Net classes directly.

You can not call .Net libraries from "unmanaged" code.
 

agraham

Expert
Licensed User
Longtime User
So - from this point of view i can't see any advantage the .net is giving to me.
Coding and application safety. Managed (.NET) programming is the future. Silverlight, Windows Programming Foundation and Windows Communication Foundation are all .NET based. More will follow. .Net is available on Unix/Linux under the guise of the Mono project http://www.mono-project.com/Main_Page Check the .NET entry on Wikipedia.
Does this mean, a B4P Lib is always a wrapper lib for the CLR ( or something else?
In that they are written to run under the CLR yes. But the CLR together with the .NET compilers provide the ability to access conventional DLLs (termed P/Invoke - platform invoke) and COM components using what are known as Interop Assemblieshttp://www.b4x.com/forum/showthread.php?t=1854
Can't i use .NET classes without the use of such a wrapper lib..?
No!
is a B4P lib different from a usual windows dll...? Tried to involve a normal windows DLL, but this didn't work - got an error message ( something related to assemblies...;-)
Yes. Read this http://www.b4x.com/forum/showthread.php?p=10607&highlight=just+in+time#post10607
I was waiting for such one...do you plan to expand that lib
Yes, already got TripleDES, RC2 and Rijndael implemented (dead easy after getting DES working as the symmetric algorithms share a common programming model). About to look at asymmetric algorithms.
 
Last edited:

TWELVE

Active Member
Licensed User
The .Net runtime is already installed on all devices and most of the desktops so the runtime should not be a big issue.

I disagree somehow...;-) Still a lot of boxes around without ( Windows2000) or too old versions like 1.1 versus requested 2.0 or even 3.5( e.g. WinXP without SP ).My PocketPC has only V1 and after every hardreset i have to install CF 2.0 i need for my app, because one of the libs needs it.

So still a lot of hazzle ( some apps don't start and doesn't even tell you without the required .NET Version) and no advantages at all ( executables much more bigger, although they should be smaller because of the shared resources they use, slower than native code exe...).VS2008 took 45 mins to complete the install and ate some gbytes on my hdd.Even a simple app creates exe with several mbytes in size.My 4000 source lines PureBasic compiled native exe ~ 200Kbytes in size and PureBasic Install is taking up 20Mbytes on my HDD, only.It needs a few seconds to build and compile my executable, during that period of time VS hasn't even start to torture my hard disk yet.If possible, i would avoid the use of .NET, if there's a choice.

Need some more PROs on .NET...? :)))



The door library allows you to use .Net classes directly.

Ah..then this piece is the one i was looking for i guess...:) I will try this...

Thanks Erel for your good work and the good support...!

cheers

TWELVE
 

TWELVE

Active Member
Licensed User
Yes, already got TripleDES, RC2 and Rijndael implemented (dead easy after getting DES working as the symmetric algorithms share a common programming model).

Erel is your boss...? If not, he should pay you for that work..at least..:)))
Your libs make B4P much more valuable.Chances to get some functionality
built into the B4P core..?

About to look at asymmetric algorithms

That's the interesting stuff...so SSL is then much closer as i thought...? :)))

cheers

TWELVE
 

agraham

Expert
Licensed User
Longtime User
Erel is your boss...?
No. I'm just an retired (early) System Designer keeping my interest up and my hand in (or vice versa). I do have a Paypal account though ;)

That's the interesting stuff...so SSL is then much closer as i thought...? :)))
I've no idea about SSL - but if you say so :)
 

TWELVE

Active Member
Licensed User
You'll come on side one day when you see the light.

Maybe...or maybe not..if i was following what Microsoft wants me to do all the time, i would end up very badly...and not the owner of my own pc anymore..:)) You know...TPM..:))

So it might be they do a good job from their perspective of view how programming has to be done, but that's not imperatively also the best way for me..:)) If MS keeps going this way, they could end up losing their leadership one day.That's good, because they will then clear the way for someone else who can provide us with a slim & fast operating system...think of AMIGA...:))

cheers

TWELVE
 

agraham

Expert
Licensed User
Longtime User
Unix Crypt would be a good expansion
For a bit of light relief I located the source of crypt and looked at. It is HORRIBLE in that it modifies the DES algorithm itself do do it's salting so you can't use a standard DES implementation to implement it.

So for a laugh I forced that original C source, containing the modified DES algorithm, through the .NET C# compiler and stuck it in a library. It should run under .NET1.0 and 2.0 and on device and desktop. It seems to work in that it returns something and as the program changes were syntactical it might even be correct. There might have been a deal-breaker that altered the final output so you can only try it against the real thing.

EDIT : I incorrectly assumed the returned length was 8 bytes, it's longer, use this amendment
B4X:
   For i = 0 To ArrayLen(code())-1
      str = str & Chr(code(i))
   Next
 

Attachments

  • CryptDLLdemo.zip
    3.9 KB · Views: 328
Last edited:

TWELVE

Active Member
Licensed User
Hi agraham,

as always: thx very much ! Sorry for the delay, but i was busy with adding other stuff and fixing my code, so i put the crypt thing on hold until now.

I will try to embedd this now and report whether everything works ok or not.


cheers

TWELVE
 
Top