4 Replies Latest reply on Aug 7, 2009 10:48 AM by Jason175

    Getting encrypted data from file to decrypt

    Jason175

      I am writing an AIR application which will decrypt an encrypted file. These files can be a variety of formats (pdf, xls, doc). This application will be replacing one that our PC users are currently using (we now need cross platform).

       

      I have the decryption algorthm (C++) am fairly new to actionscript.

       

      What is the best way to get this raw data (byte by byte) from the encrypted file so that I use it to run the decryption algorithm and decrypt the file.

       

      I have not done anything like this before so I may not be giving you all of the necessary information. If anything else is needed, let me know.,,,I can give you any info you need, as I have a copy of the algorithm used to decrypt the files.

       

       

      Thanks,

      Jason

        • 2. Re: Getting encrypted data from file to decrypt
          Jason175 Level 1

          Thanks for the reply.

           

          Filestream is allowing me to gets the data from the text file, however it seems to be having trouble intrepretting the encrypted characters.

          I am using the charCodeAt function to get the ascii characters codes for the encrypted data, however when I run it in debug mode and look at the values it is getting for these characters and then run the (working) c++ decrypter side by side with it to compare the values....they are different.

          The "standard" characters remain the same, however the others differ...here is an example:

           

          Character: þ

          In C++ program it is read as:   -2

          In Air program it is reas as:     245

           

          Hopefully this is something simple that I am doing wrong and someone has seen it before...

           

          Thanks a lot,

          Jason

          • 3. Re: Getting encrypted data from file to decrypt
            alevicki Level 2

            It is hard to say what is wrong without seeing your code, but here are a couple of things you could try:

            1) Ideally you could just pass the bytes to your decryption code instead of having to convert them to characters.  The decryption algorithm should be converting whatever characters you pass in to bytes anyway.

            2) You could try using the readUTFBytes function on the FileStream object.  This will return a string for you so you don't have to worry about converting the bytes that you read in.  This will only work if the bytes were outputted in the same UTF-8 encoding.

            • 4. Re: Getting encrypted data from file to decrypt
              Jason175 Level 1

              If I subtract 256 from any value AIR is getting that is greater than 128, I get the correct value (corresponding with the C++ code).

               

              This is probably the solution, but do you know what would cause this?

               

              C++ is using an unsigned char...I'm not sure how that effects it.