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

Discussion in 'Questions (Windows Mobile)' started by TWELVE, Apr 30, 2008.


    TWELVE Active Member Licensed User


    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

    Last edited: Apr 30, 2008
  2. agraham

    agraham Expert Licensed 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.

    Attached Files:

    Last edited: Apr 30, 2008
  3. Elrick

    Elrick Member Licensed User

  4. agraham

    agraham Expert Licensed User

    Thanks for the reminder Elrick - you know I'd forgotten that I'd already done that! :signOops: Age creeping up no doubt? :(
    Last edited: Apr 30, 2008
  5. Elrick

    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!
  6. LineCutter

    LineCutter Active Member Licensed User

    You could have left him to it, it would only have taken 45 minutes to recreate the MD5 library!
    :sign0103: :sign0188:
  7. dzt

    dzt Active Member Licensed User

  8. Elrick

    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..! C / Linux Programmers here at all...? :))) Crypt is a standard unix encryption function...see this link:

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


  10. agraham

    agraham Expert Licensed User

    It may be standard but where is the algorithm?

    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 which implements MD5 and DES.
  11. TWELVE

    TWELVE Active Member Licensed User

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

    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.

    - 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...;-) ).

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


    Last edited: May 1, 2008
  12. Erel

    Erel Administrator Staff 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.

    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.
  13. agraham

    agraham Expert Licensed User

    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 Check the .NET entry on Wikipedia.
    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 Assemblies
    Yes. Read this
    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: May 1, 2008
  14. TWELVE

    TWELVE Active Member Licensed User

    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...? :)))

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


  15. TWELVE

    TWELVE Active Member Licensed User

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

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


  16. agraham

    agraham Expert Licensed User

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

    I've no idea about SSL - but if you say so :)
  17. agraham

    agraham Expert Licensed User

    You'll come on side one day when you see the light.:)

    It took me a few years before I cottoned on to the advantages of .NET but I wouldn't go back now.
  18. TWELVE

    TWELVE Active Member Licensed User

    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...:))


  19. agraham

    agraham Expert Licensed User

    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
    For i = 0 To ArrayLen(code())-1
          str = str & 

    Attached Files:

    Last edited: May 3, 2008
  20. TWELVE

    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.


  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice