Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The CryptoJS API doesn't provide a way to specify a salt or the number of rounds for SHA256. You could add a salt manually if necessary, and specifying rounds doesn't make sense since "plain" SHA256 always uses a fixed number of rounds (64).</p> <p>The number of rounds in PHP's <code>crypt()</code> actually defines how often the SHA256 algorithm is applied consecutively, in order to increase the complexity of brute force attacks. The <a href="https://github.com/php/php-src/blob/master/ext/standard/crypt_sha256.c" rel="nofollow">PHP source code</a> comments on this as follows: <em>"Repeatedly run the collected hash value through SHA256 to burn CPU cycles"</em>.</p> <p>As you can see in the source code (<a href="https://github.com/php/php-src/blob/master/ext/standard/crypt.c" rel="nofollow">here</a> and <a href="https://github.com/php/php-src/blob/master/ext/standard/crypt_sha256.c" rel="nofollow">here</a>), <code>crypt()</code> is actually a key derivation function that only makes use of SHA256 to generate cryptographically secure, salted hashes. So it also doesn't simply append the given salt to the key, instead it's a more elaborate process.</p> <p><strong>Therefore, it is not possible to get the same results with the algorithms provided by CryptoJS.</strong></p> <p><code>crypt()</code> is mainly intended for password hashing. So if you need the hashes for another purpose, <code>hash()</code> is a good alternative (and of course creates exactly the same results as <code>CryptoJS.SHA256()</code>).</p> <p>However, bear in mind that any cryptography with JavaScript is generally <a href="http://www.matasano.com/articles/javascript-cryptography/" rel="nofollow">considered harmful</a>. Hence, you should better use SSL in your application, if possible, and generate the hashes server side. If this is an option, have a look at <a href="http://codahale.com/how-to-safely-store-a-password/" rel="nofollow">bcrypt</a>.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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