Skip to main content
Known Participant
July 22, 2009
Question

BITXOR in ColdFusion from PHP

  • July 22, 2009
  • 1 reply
  • 2219 views

Hello,

im trying to rewrite bitXOR code from PHP to Coldfusion:

token is byteArray

string is String

PHP:

for($i = 0;$i < $length; $i++){

$xor .= ($token[$i] ^ $string[$i]);

}

Here is what i have so far in CF:

<cfscript >

var theXOR=""; 

var i=1;

var token = CharsetEncode(token,"utf-8");

for (; i le length; i++ ) {

        xor = xor & rJustify(formatbaseN(bitXor(asc(mid(token,i,1)),asc(mid(string,i,1))),"16"),2);      

    }

</cfscript>

The problem is that the CF result is not the same as PHP.

PHP code does what I need.

What I'm doing wrong?

Thanks for help.

    This topic has been closed for replies.

    1 reply

    ilssac
    Inspiring
    July 22, 2009
    alex_cvAuthor
    Known Participant
    July 22, 2009

    BitXOR function accept just integer so it wont help. I found bitXOR for 2 strings: http://cflib.org/index.cfm?event=page.udfbyid&udfid=1599

    but it doesnt work too. The result is not the same as original PHP function.

    Inspiring
    July 22, 2009

    What do you mean by "does not work"?