he!
für einen shop ist es nötig, checksummen zu berechnen. diese werte kommen allerdings von foxpro,
die allerdings dem ergebnis von crc32() unter php garnicht ähnlich sind. also hat der foxpro
programmierer eine foxpro-routine für crc32 aus dem internet inkl. quelltext gefischt, welche
ich nun in php umgesetzt habe. leider bekommen wir auch hier völlig andere ergebnisse.
hier der haupteil in foxpro:
Init-Methode:
*------ inicialization This.CRCTbl -----------------------*
This.CRCTbl(001) = 0x00000000
...
This.CRCTbl(256) = 0x2d02ef8d
Methode: STRCRC32
lParameters tcStr
Local lnCrc32, ix, lnZ, lnByte
If Empty(tcStr)
Return 0 &&Space(8)
Else
lnCrc32 = 0xFFFFFFFF
For iX = 1 To Len(tcStr)
lnByte = Asc(SubStr(tcStr, iX, 1))
lnZ = BitXor(lnByte, BitAnd(lnCrc32, 0x000000FF))
lnCrc32 = BitXor(This.CRCTbl(lnZ + 1), BitRShift(lnCrc32, 8))
EndFor
lnCrc32 = BitNot(lnCrc32)
If lnCRC32 < 0
lnCRC32 = Int(lnCRC32 + 0x100000000)
EndIf
* Return This.DecToHex(lnCrc32)
Return (lnCrc32)
EndIf
hier in php:
function STRCRC32($tcStr)
{
$CRCTbl[001] = 0x00000000;
...
$CRCTbl[256] = 0x2d02ef8d;
$lnCrc32 = 0xFFFFFFFF;
For ($iX=0; $iX<strlen($tcStr); $iX++)
{
$lnByte = ord(SubStr($tcStr, $iX, 1));
$lnZ = $lnByte ^ ($lnCrc32 & 0x000000FF);
$lnCrc32 = $CRCTbl[$lnZ + 1] ^ ($lnCrc32 >> 8);
}
$lnCrc32 = ~$lnCrc32;
If ($lnCRC32 < 0) $lnCRC32 = Intval($lnCRC32 + 0x100000000);
Return $lnCrc32;
}
echo STRCRC32("A");
irgendetwas läuft da schief. vieleicht kennt sich ja jemand von euch damit aus.
gruss
j.b.