convert hash in c# to php sockets -
i have function in c#.
public static implicit operator guid(tcppacketreader p) { byte[] tmp = new byte[16]; array.copy(p.data.toarray(), p.position, tmp, 0, tmp.length); p.position += 16; using (md5 md5 = md5.create()) tmp = md5.computehash(tmp); //wtf? return new guid(tmp); }
i'm trying replicate functionality in php. problem when tmp variable in array. return like:
array[5, 49, 42, 5, 254, 160, 191, 64, 79, 37, 216, 169, 201, 181, 13, 0, 59, 187]
and don't know how computehash(tmp) in php. i've tried md5() php's function return null object. i'm googled lot nothing successful. know how that?
first: md5.create().computehash(tmp);
makes bit more readable (in case)
what c# take array of bytes. php does, take string. if want input php array of bytes, first have convert string
$tmp = md5(implode(array_map("chr", $tmp))); // implode , array_map turn tmp string, array containing byte's ascii codes (1-255)
c# md5.computehash(tmp)
returns array of bytes of hash
php md5(tmp)
returns string containing hexadecimal representation of hash
since provided no code php, can't answer question. should on way.
Comments
Post a Comment