Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts

    Apple Mac problem

    I have an order form which encrypts a credit card number (str) using a key (target). The result is encString.

    This works fine in all browsers except Apple. A customer's browser details are:-
    Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/124 (KHTML, like Gecko) Safari/125.1

    Everything works but the encrypted string retuned is the string or value 0800000360 repeated 8 times. That is, rubbish.

    Could anyone kindly have a look at advise me what is the problem?

    Code:
    function roxtpyrcne(str, target) {
      var prand = "";
      for (var i=0; i<target.length; i++) {
        prand += target.charCodeAt(i).toString();
      }
      var sPos = Math.floor(prand.length / 5);
      var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos*2) + prand.charAt(sPos*3) + prand.charAt(sPos*4) + prand.charAt(sPos*5));
      var incr = Math.ceil(target.length / 2);
      var modu = Math.pow(2, 31) - 1;
      var salt = Math.round(Math.random() * 1000000000) % 100000000;
      prand += salt;
      while (prand.length > 10) {
        prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
      }
      prand = (mult * prand + incr) % modu;
      var encChar = "";
      var encString = "";
      for (var i=0; i<str.length; i++) {
        encChar = parseInt(str.charCodeAt(i) ^ Math.floor((prand / modu) * 255));
        if (encChar < 16) {encString += "0" + encChar.toString(16)} 
        else encString += encChar.toString(16);
        prand = (mult * prand + incr) % modu;
      }
      salt = salt.toString(16);
      while (salt.length < 8) {salt = "0" + salt}
      encString += salt;
      return encString;
    }

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Mayday! Willy, hemebond, jbot, kor, why this unaccustomed reticence?

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M
    Mayday! Willy, hemebond, jbot, kor, why this unaccustomed reticence?
    i'm a tad busy this morning ... will have a wee gander at it later, mate.
    *keep it simple (TM)

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Alas! It is plain that the biggest fool can ask a question which the wisest man cannot answer.

  • #5
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Reading through the code I couldn't find anything in particular, and doing a few test runs it worked just fine here. It might be that there are some kind of errors in KJS when it comes to math that shows up in edge cases though. (Modulo versus Remainder is one potential such case. JavaScript should only have Remainder.) I could also guess that a different character encoding to what is expected could give such errors, except that I believe OSX uses Unicode everywhere.

    Is this a user that you are able to contact or just an error you found in your logs? If you can contact the user, try to get a recording of the src, target and initial salt variables that causes the problem.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Thank you so much, Liorean! The error only shows up in the completed form as it reaches me, and I don't think the users are sufficiently knowledgable to do as you suggest.

    I am afraid that I do not know what KJS and OXS are/mean.

    Liorean said Philip M is a genius.
    Sorry, I'll do that again with different punctuation.
    Liorean, said Philip M, is a genius.

  • #7
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    KJS is the JavaScript engine that is the base for the Konqueror browser (X11 systems) made by KDE. When building Safari, Apple chose KJS as the JavaScript engine to base their JavaScriptCore framework on. This framework is the scripting environment of Safari.

    OSX is the popular name for Mac OS X 10.x, as opposed to the old operative systems of the Mac (System 7, OS 8, OS 9, commonly grouped together as MacOS).
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •