Note that there are some explanatory texts on larger screens.

plurals
  1. POStrings in Javascript and PHP
    primarykey
    data
    text
    <p>I have a question about strings in Javascript and PHP. Currently, I have a client side script (in Javascript obviously) that gets the string from an html form and prints it out. As of right now, I just copy it into the php script (on the server obviously). Later, when I know the scripts work I am going to have the javascript send it to the server automatically but right now I want to make sure that the code I have written is correct. When I do the copying of the string, I get two different sha1 hashes. I suspect that there are different null terminators or something quirky like that because when I print them out, they are are same amount of characters and match exactly (at least to the naked eye). I was wondering if anyone knew how to fix this to make it the same hash. Thanks. The Javascript code that deals with the msg. The javascript gets the msg from a html document. The javascript sha1 hash is from <a href="http://crypto-js.googlecode.com/files/2.5.3-crypto-sha1.js" rel="nofollow">http://crypto-js.googlecode.com/files/2.5.3-crypto-sha1.js</a></p> <pre><code>var msg=document.input.msg.value; digert = digest + Crypto.SHA1(msg); digestBytes = Crypto.SHA1(msg, {asBytes: true}); digestString = Crypto.SHA1(msg, {asString: true}); </code></pre> <p>The code php code that deals with the msg. It gets the message from a html form that posts it to a php script.</p> <pre><code>//finds the starting point of the message $start_MSG = stripos($_POST["message"], ' ')+1; //stores the message in a global variable $GLOBALS['msg'] = substr($_POST["message"], $start_MSG); $temp_hash2 = sha1($_POST["message"], false); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    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