3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /** * @return array */ function crc64Table() { $crc64tab = []; // ECMA polynomial $poly64rev = (0xC96C5795 << 32) | 0xD7870F42; echo sprintf("%x", $poly64rev) . PHP_EOL; // ISO polynomial // $poly64rev = (0xD8 << 56); for ($i = 0; $i < 256; $i++) { for ($part = $i, $bit = 0; $bit < 8; $bit++) { if ($part & 1) { $part = ($part >> 1) ^ $poly64rev; } else { $part = ($part >> 1) ; } } $crc64tab[$i] = $part; } return $crc64tab; } /** * @param string $string * @param string $format * @return mixed * * Formats: * crc64('php'); // afe4e823e7cef190 * crc64('php', '0x%x'); // 0xafe4e823e7cef190 * crc64('php', '0x%X'); // 0xAFE4E823E7CEF190 * crc64('php', '%d'); // -5772233581471534704 signed int * crc64('php', '%u'); // 12674510492238016912 unsigned int */ function crc64($string, $format = '%x') { static $crc64tab; if ($crc64tab === null) { $crc64tab = crc64Table(); } print_r($crc64tab); $crc = 0; for ($i = 0; $i < strlen($string); $i++) { $crc = $crc64tab[($crc ^ ord($string[$i])) & 0xff] ^ (($crc >> 8) & ~(0xff << 56)); } return sprintf($format, $crc); } echo crc64("123456", "%u");
based on YZaIP
Output for 5.6.0 - 7.3.0beta1
c96c5795d7870f42 Array ( [0] => 0 [1] => -3085444315713413265 [2] => 4072439713162633307 [3] => -1321108396649742540 [4] => -2030908455953408461 [5] => 3962762205633970524 [6] => -2642216793299485080 [7] => 1043350142908408071 [8] => -4061816911906816922 [9] => 1337511605431821065 [10] => -61448001148806083 [11] => 3029794314276914002 [12] => 2625955430124347989 [13] => -1054114772591133382 [14] => 2086700285816816142 [15] => -3901456050092106399 [16] => 2133476111742625353 [17] => -3984017134172489434 [18] => 2675023210863642130 [19] => -1138887535845140099 [20] => -122896002297612166 [21] => 3126956105307744021 [22] => -4120981765609449439 [23] => 1432452909921716046 [24] => -2721821029974549969 [25] => 1086610575427536192 [26] => -2108229545182266764 [27] => 4003802151612196123 [28] => 4173400571633632284 [29] => -1385796919237420173 [30] => 103252813284516935 [31] => -3152344517474682072 [32] => 4266952223485250706 [33] => -1289983537625066499 [34] => 266684513967828169 [35] => -2982165148308786266 [36] => -2817140155349364063 [37] => 993550912105401806 [38] => -2277775071690280198 [39] => 3841002163317665173 [40] => -245792004595224332 [41] => 3006304240652988315 [42] => -4318121709686697809 [43] => 1242078226581262272 [44] => 2253496349976112839 [45] => -3861755026140532312 [46] => 2864905819843432092 [47] => -942241796533988877 [48] => 2786852171895122651 [49] => -899963500381407820 [50] => 2173221150855072384 [51] => -3817194715893049873 [52] => -4216459090364533528 [53] => 1176121689839086471 [54] => -146342130152221517 [55] => 2942638524299283420 [56] => -2230016009936628035 [57] => 3756891590106040786 [58] => -2771593838474840346 [59] => 911731159282280841 [60] => 206505626569033870 [61] => -2885704018667825183 [62] => 4204551784913758421 [63] => -1191240393889171526 [64] => -1966336036761794655 [65] => 3573720056131279054 [66] => -2579967075250132998 [67] => 656488857531086997 [68] => 533369027935656338 [69] => -3294201776321100035 [70] => 4603485971236551113 [71] => -1527684924412582234 [72] => 2528679669660466119 [73] => -704285038837341016 [74] => 1987101824210803612 [75] => -3549445452212812557 [76] => -4555550143380560396 [77] => 1578832700632283803 [78] => -557504002484157009 [79] => 3273296342322354880 [80] => -491584009190448664 [81] => 3171596595428310663 [82] => -4491851736156192333 [83] => 1479415001656008412 [84] => 1944791386414890971 [85] => -3471424530032303948 [86] => 2484156453162524544 [87] => -623973261371752209 [88] => 4506992699952225678 [89] => -1467538762781621535 [90] => 434662977949334997 [91] => -3231764759405026630 [92] => -2495893045487008835 [93] => 608692668205522130 [94] => -1884483593067977754 [95] => 3528205914723515529 [96] => -2341474082435544269 [97] => 769874761655391324 [98] => -1799927000762815640 [99] => 3615004376894190599 [100] => 4346442301710144768 [101] => -1621323900353951121 [102] => 348356521486890331 [103] => -3315827078291658188 [104] => 1738651911797339989 [105] => -3670818466503546822 [106] => 2352243379678172942 [107] => -753626872870598559 [108] => -292684260304443034 [109] => 3377244012864075273 [110] => -4362832036101879491 [111] => 1610696431538230866 [112] => -4460032019873256070 [113] => 1672106755350426133 [114] => -387592324158943967 [115] => 3436442691325514318 [116] => 2434770672822088521 [117] => -800435974327882714 [118] => 1823462318564561682 [119] => -3719848019605156739 [120] => 413011253138067740 [121] => -3416821212294164877 [122] => 4413380146984661319 [123] => -1724538486000751064 [124] => -1843225626022523089 [125] => 3694570936232611904 [126] => -2382480787778343052 [127] => 847229675643088923 [128] => -3932672073523589310 [129] => 2036219856581316653 [130] => -1015454227976704231 [131] => 2649855443440038006 [132] => 3079499046621565297 [133] => -30724000574403042 [134] => 1312977715062173994 [135] => -4100827659541434811 [136] => 1066738055871312676 [137] => -2602064489121649589 [138] => 3911911513062445951 [139] => -2060490882804724720 [140] => -1360910514987274985 [141] => 4049685660073833080 [142] => -3055369848825164468 [143] => 51626406642258467 [144] => -3100738593271551733 [145] => 133342256983914084 [146] => -1408570077674682032 [147] => 4133614257442100799 [148] => 3974203648421607224 [149] => -2159060854843348905 [150] => 1126748174988056419 [151] => -2698412912135059444 [152] => 1393426085947561325 [153] => -4145496273068389886 [154] => 3157665401264567606 [155] => -73171065076110759 [156] => -1115008004968314018 [157] => 2713698732288955441 [158] => -4034516668756186363 [159] => 2102275892456879210 [160] => -983168018380897328 [161] => 2843276989115571391 [162] => -3828301907112139893 [163] => 2301742985618275556 [164] => 1264339834830233059 [165] => -4276841986238332276 [166] => 2958830003312016824 [167] => -278752001242078505 [168] => 3889582772829781942 [169] => -2245925868078096167 [170] => 972395693207445485 [171] => -2859530654652530558 [172] => -3014507491482394235 [173] => 217331488974667498 [174] => -1247946522743504418 [175] => 4287474682041982641 [176] => -1170737041217772135 [177] => 4246604603404450550 [178] => -2935077525563243070 [179] => 174178260743445165 [180] => 869325955898669994 [181] => -2792728851959339835 [182] => 3788724716842081265 [183] => -2181416018050939746 [184] => 2909663823571720703 [185] => -193796162079471984 [186] => 1217385336411044260 [187] => -4194178099741727029 [188] => -3768967186135955508 [189] => 2206690073492330659 [190] => -921612813011261545 [191] => 2745940927395969272 [192] => 3304090025104541923 [193] => -507727113988352116 [194] => 1539749523310782648 [195] => -4580153439737907241 [196] => -3599854001525631280 [197] => 1955955756531222975 [198] => -680455257493637493 [199] => 2567268607887944164 [200] => -1550369296635775867 [201] => 4563756007707995114 [202] => -3242647800707902242 [203] => 563374087494028209 [204] => 696713042973780662 [205] => -2556509205193148967 [206] => 3544067398650153709 [207] => -2017258334378093182 [208] => 3477303823594679978 [209] => -1914150953556069947 [210] => 632169917415116529 [211] => -2455684940141948514 [212] => -3201743897311530855 [213] => 486197846603722742 [214] => -1507253745741197118 [215] => 4484287849048264621 [216] => -585368520608886068 [217] => 2507967127547153827 [218] => -3502555617142639977 [219] => 1894362358421040632 [220] => 1454831911785860351 [221] => -4530949616484396144 [222] => 3221392863076461732 [223] => -460806406505630773 [224] => 1652045012552270961 [225] => -4340499646116455650 [226] => 3344213510700852266 [227] => -340227628746818747 [228] => -775184648317887934 [229] => 2311385739168466221 [230] => -3622640138662856167 [231] => 1772033699325076854 [232] => -3365111247061321705 [233] => 316084958707558264 [234] => -1600871948655765428 [235] => 4388410184148125475 [236] => 3646924637129123364 [237] => -1751277808571319989 [238] => 727415955892930175 [239] => -2362700631491978992 [240] => 826022506276135480 [241] => -2424955673101566633 [242] => 3743240334374699619 [243] => -1811320069331428084 [244] => -1682555623530660853 [245] => 4433811619465208676 [246] => -3449076972001502128 [247] => 363707977946465087 [248] => -3686451252045046178 [249] => 1871620167187349809 [250] => -841277811765330427 [251] => 2413193790952595818 [252] => 3388918702572355693 [253] => -420638905882665214 [254] => 1694459351286177846 [255] => -4418698142402789543 ) 16855291211478540272