...

View Full Version : Apple Mac problem



Philip M
01-26-2005, 08:28 AM
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?




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

Philip M
01-27-2005, 08:37 AM
Mayday! Willy, hemebond, jbot, kor, why this unaccustomed reticence?
;) :D ;)

jbot
01-27-2005, 11:42 AM
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. :thumbsup:

Philip M
01-28-2005, 08:04 AM
Alas! It is plain that the biggest fool can ask a question which the wisest man cannot answer. :p

liorean
01-28-2005, 01:45 PM
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.

Philip M
01-28-2005, 07:22 PM
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.

liorean
01-28-2005, 08:02 PM
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).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum