Ambrosia Garden Archive
    • RealBasic related to EV help requested


      I've a program that correctly decrypts old EV/O pilot files and uses the data to generate EVN pilot files, but it is a dog to run. Resource loading, decryption and modification of the decrypted resources is pretty snappy, but when I go to encrypt everything, it's painful.

      The method used to encrypt and decrypt data is the same. The problem is the form the data takes.

      RealBasic presents the resource data as a string of characters (what you see in the right column if you're using ResEdit). To decrypt things, I convert the characters to a number to put through the decryption algorythm. When it comes out, I convert the resulting number to a hex string for later manipulation.

      The problem is, to use the subroutine again to encrypt the data, it has to be as a character string.

      There's a painful routine I have where it reads my hex string 2 characters at a time and converts those two characters into a chr. Essentially I'm doing this:

      for i=1 to theLength step 2
      preResult=chr(val("&h;"+(mid(theString,i,2))))
      theResult=theResult+preResult
      next

      The resulting string goes into the encryption algorythm and when it comes out, I need to change it into a chr string again to write to the resource! I could use memory blocks I suppose, but I feel like this entire step could be skipped with the correct code.

      Ug.

      I know there has to be a better way, but as I'm teaching myself, I havn't found it. Any advice from folks?

      -STH

      ------------------
      "Create enigmas, not explanations." -Robert Smithson

    • Well, MemoryBlocks are certainly what comes to mind first. It might also be worthwhile to try using ChrB rather than Chr; I don't know if it would actually be faster, but it might well be, since it doesn't have to check whether to use 1-byte or 2-byte characters.

      ------------------
      David Arthur
      (url="http://"http://davidarthur.evula.net/")davidarthur.evula.net(/url): MissionComputer and the Talon plug-in for the original Escape Velocity
      (url="http://"http://www.ev-nova.net/")EV-Nova.net(/url): Forums and Site Now Open