Closed Thread Icon

Topic awaiting preservation: Server decoding (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21732" title="Pages that link to Topic awaiting preservation: Server decoding (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Server decoding <span class="small">(Page 1 of 1)</span>\

 
amikael
Bipolar (III) Inmate

From: övik
Insane since: Dec 2002

posted posted 05-09-2004 23:14

Anyone see why this wont run on the server?
It does'nt seem to exist an array called 'digits'??
(ASP - using Jscript.)

code:
var digits = new Array();

for (var i=0; i<26; i++)
{
digits["A".charCodeAt(0)+i] = i;
digits["a".charCodeAt(0)+i] = i+26;
}
for (var i=0; i<10; i++)
{
digits["0".charCodeAt(0)+i] = i+52;
}

digits[0x2b] = 62;
digits[0x2f] = 63;

function setDecodeBase64(string)
{
var val = "";
val += (digits[string.substr(0,1).charCodeAt(0)] << 2);
val += (digits[string.substr(1,1).charCodeAt(0)] >> 4);
val += (digits[string.substr(1,1).charCodeAt(0)] & 0xf) << 12;
val += ((digits[string.substr(2,1).charCodeAt(0)] >> 2) << 8);
val += ((digits[string.substr(2,1).charCodeAt(0)] & 0x3) << 22);
val += (digits[string.substr(3,1).charCodeAt(0)] << 16);
return val;
}



(^-^)b

(Edited by WarMage on 05-10-2004 01:14)

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 05-10-2004 00:59

amikael: First, to avoid the problems of seeing your code unindented and "polluted" by linkwords and other slimies, you should put it in the [ code ] UBB code.
Next, have you tried to introspect the digits array in the setDecodeBase64() function ? Does the code the function work if you put it at the same scope level as the initialization of the array ?
Finally, you can get rid of your substr() calls and simply access the right character in the string via the parameter of the charCodeAt() function

Cheers,

[edit] Thank you WarMage [/edit]



(Edited by poi on 05-10-2004 01:44)

« BackwardsOnwards »

Show Forum Drop Down Menu