Help with Encoding/Decoding data for payment Gateways

From: Date: Mon, 20 Aug 2001 23:20:02 +0000
Subject: Help with Encoding/Decoding data for payment Gateways
Groups: php.general 
Request: Send a blank email to php-general+get-63569@lists.php.net to get a copy of this message
I'm writing a script to post/validate payments to www.clickbank.com .... They provide a method for passing encrypted data to them, and if you get it back on your "thank you" page, you know 100% that the customer has paid. Unfortunately, the validation routines are only available in Perl and C... and unfortunately, I'm not that proficient in either, at least not enough to duplicate it in PHP. Could someone tell me what is happening here, and if there is a good way in PHP to duplicate it. I run into this type of thing often with payment processors, and am forced to use less "good" methods.... sub valid { ### Copyright Keynetics Inc. Patents pending. my($a,$b,$c,$h,$i,$l,$q,$w,$x,$y,$z,@s,@v); ############################### $a='YOUR_SECRET_KEY_GOES_HERE'; ############################### $q='&'.substr($ENV{'QUERY_STRING'},0,256); $q=~/\Wseed=(\w+)/; $b=$1; $q=~/\Wcbpop=(\w+)/; $c=$1; return 0 unless $a&&$b&&$c; $h=0x80000000; $l=0x7fffffff; $q=''; $w=uc "$a $b"; $x=$y=$z=17; @v=unpack("C*",$w); $n=1+$#v; for($i=0;$i<256;$i++) { $w=(($x&$l)+($y&$l))^(($x^$y)&$h); $w=($w<<$z)|($w>>(32-$z)); $w=(($w&$l)+$v[$i%$n])^($w&$h); $s[$i&7]+=$w&31; $z=$y&31; $y=$x; $x=$w; } for ($i=0;$i<8;$i++) { $q.=substr('0123456789BCDEFGHJKLMNPQRSTVWXYZ',$s[$i]&31,1); } return $c eq $q; } Any help/pointers to resources would be greatly appreciated. Thanks in advance. -Brian Tanner

« previous php.general (#63569) next »