Reading encrypted files in Java Script.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wanni
    New Member
    • Jan 2009
    • 13

    Reading encrypted files in Java Script.

    Hi All,
    I want to store data in a encypted form (in form of some file) and later on i want to read encrypted data in Java Script and want to pass that encrypted buffer to some Active X component.

    My first question how should i read/load a file in java Script and read its contents.?
    Also is it possible to parse data in javascript?

    Regards
    Wanni.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    if the file is on the client's machine you're out of luck (Javascript isn't allowed file system access). to access a file on the server you can use AJAX. but if you do server side stuff, maybe you don't need Javascript at all for ActiveX (besides the fact that ActiveX only works in IE).

    regards

    Comment

    • wanni
      New Member
      • Jan 2009
      • 13

      #3
      Thanks for your response.
      Yeah my encrypted file resides on server, that means i have to use AJAX for reading contents of that file.

      Actually my purpose is to send encrypted Data to ActiceX functions. So other possibility i am thinking that i can access encrypted file contents directly in ActiveX. So in order to achieve this i have to get the Web Page URLin ActiceX and through that URL i can get the path where file is present and after that i can access the contents of that file directly in ActiveX.

      Can this is possible in ActiveX?

      Regards,
      wanni.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by wanni
        Can this is possible in ActiveX?
        unfortunately I can't tell you, because
        • I don't have IE
        • ActiveX is not supported by browsers other than IE (so you'd exclude quite a lot of people)
        • in my opinion, IE is the worst browser available

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          What exactly are you trying to do here (by reading encrypted files with ActiveX)?

          If it resides on the server, let the server-side code decrypt it and then allow a download which you can use in any program on the client.

          Comment

          • wanni
            New Member
            • Jan 2009
            • 13

            #6
            Hi,
            Yeah i know i can use server side scripting in order to push the content on client side, but i dont want to use any server scripting language on server side.

            Is there are any API's/Functions in ActiveX which downloads the file residing on server by opening some http steams etc.

            regards,
            wanni

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              It probably is possible, but you'll need to give permissions and it should be used sparingly and with caution. Check the documentation on the MSDN website.

              Comment

              • wanni
                New Member
                • Jan 2009
                • 13

                #8
                Thanks for all your response.
                i Have one more question regarding Ajax. I want to read binary file in JavaScript.

                I have code the following lines.

                Code:
                    var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
                	 
                    xmlHttp.onreadystatechange = function() { 
                        if (xmlHttp.readyState == 4) { 
                	result = xmlHttp.responseStream;
                	alert(result);
                        } 
                    }
                But this is not working. Can u tell what is problem in above code.

                Regards
                wanni.
                Last edited by Dormilich; Jan 30 '09, 02:18 PM. Reason: added [code] tags

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #9
                  the official docs (http://www.w3.org/TR/XMLHttpRequest/) do not mention this property (responseStream ), so you can't expect it to be always working.

                  It seems to be part of "MSXML2.XMLHTTP .3.0" as source for the XMLHttpRequest.

                  Comment

                  • wanni
                    New Member
                    • Jan 2009
                    • 13

                    #10
                    Thanks for your response.
                    Can i believe there is no other way of reading binary files in JavaScript in IE.

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      If it's just IE, you can use responseBody in place of responseStream.

                      Then, in ActiveX, you could use the FileSystemObjec t, and failing that, ADO.Stream.

                      Comment

                      Working...