bit shifting in c# vs PHP -


i'm porting class c# php. part i'm having trouble creates hash of string in c# shifting bits repeatedly. php code gives me same output first few iterations starts producing wildly different results c# version. assume string i'm hashing 'ddc74'.

here's c#:

uint hash = 0;  foreach (byte b in system.text.encoding.unicode.getbytes(s)) {       hash += b;       hash += (hash << 10);       hash ^= (hash >> 6); } 

and here's php:

$hash = 0; settype($hash, "integer");  // convert string unicode array because c# version uses each unicode byte. $source = mb_convert_encoding($s, 'utf-16le', 'utf-8'); $source = unpack('c*', $source); foreach ($source $b) {     var_dump(array('geteightbytehash() b : ' => $b,));      $hash += $b;     $hash += ($hash << 10);     $hash ^= ($hash >> 6); } 

can spot i'm doing wrong? php code goes off rails in 3rd iteration.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -