Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to mimic computeHash vb function in PHP
    primarykey
    data
    text
    <p>I am having a hell of a time trying to md5 hash this with PHP... The VB code I am trying to port to PHP uses ComputeHash which takes in a byte[] and performs a hash on the whole array.</p> <pre><code> Public Shared Function HashBytesMD5(ByVal strInput As String) As Guid Dim oHasher As Cryptography.MD5 = Cryptography.MD5.Create() Dim oEncoder As New System.Text.UTF8Encoding() Dim csData() As Byte csData = oEncoder.GetBytes(strInput) csData = oHasher.ComputeHash(oEncoder.GetBytes(strInput)) Return New Guid(csData) End Function </code></pre> <p>Right now I have the following which creates an array of ascii values. Now I need to md5 it like VB.Net does. It doesn't seem to be as straightforward as it may seem.</p> <pre><code> $passHash = $this-&gt;ConvertToASCII('123456'); $passHash = md5(serialize($passHash)); /* * Converts a string to ascii (byte) array */ function ConvertToASCII($password) { $byteArray = array(); for ($i=0; $i &lt; strlen($password); $i++) { array_push($byteArray,ord(substr($password,$i))); } return $byteArray; } </code></pre> <p>Note: the values in the first are the acii values for the characters 123456</p> <p>Byte array before computeHash md5</p> <pre><code> **index** **Value** [0] 49 [1] 50 [2] 51 [3] 52 [4] 53 [5] 54 </code></pre> <p>Byte array returned from VB computeHash function <strong>index</strong> <strong>value</strong> </p> <pre><code>[0] 225 [1] 10 [2] 220 [3] 57 [4] 73 [5] 186 [6] 89 [7] 171 [8] 190 [9] 86 [10] 224 [11] 87 [12] 242 [13] 15 [14] 136 [15] 62 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload