Indsæt den tekst, du ønsker at SHA512 hash her:

Input Begrænset til 32768 tegn

Kopier din SHA512 besked fordøje herfra.

Cookies

Please note that by viewing our site you agree to our use of cookies (see Privacy for details). You will only see this message once.

' . $algorithm . '$rounds=' . $rounds . '

Working test with above PHP functions:

%%%~COMPRESS~PRE~10~%%%

Javascript Version (broken)

Here's what I've got so far, but it isn't quite there

%%%~COMPRESS~PRE~11~%%%

javascript based on answer to SO question How to validate Symfony2 sha512 passwords using nodejs

The javascript version is using some test values:

password: secret

hash: $6$rounds=1234$56ab50921c460$P4bgd3kMX2xyWJTDOYAdow.jsXiS2TARUJW4BXifgm4czraOIDFLqZ5Ii50GLIKwYTjWwN6WrtG82omQes0cK0

  • Objective C SHA512 hash of two NSData

    Here is a Java code, which computes SHA512 hash of a byte array with salt:

    %%%~COMPRESS~PRE~12~%%%

    In Objective C, I use this algorithm for compute the hash of an NSData:

    %%%~COMPRESS~PRE~13~%%%

    This works perfectly, computes the same hash, as the Java code, if I use the same single data (i.e. the salt is nil in the Java code). The problem is that, if I want to computes hash of two NSData, i.e. there is a salt (the second parameter in the Java code is not nil). You can see that in the Java code, if the salt is not null, it performs an update, and then call the digest method. Somewhere I read that, this operation is equal with merging the two byte array (the data and salt arrays with System.arraycopy), and call the digest on the result array. However, if I do this in Objective C (with NSMutableData appendData method), I don't get the same result. How can I fix this? I can see in the CommonDigest class, there are similar methods, but I don't know, how can I use these...I think of these methods:

    %%%~COMPRESS~PRE~14~%%%

    So I would like to create a method like this:

    %%%~COMPRESS~PRE~15~%%%
  • Cookies

    Please note that by viewing our site you agree to our use of cookies (see Privacy for details). You will only see this message once.

    ' . $salt; $hashedPassword = crypt($password, $cryptSalt); return $hashedPassword;}function hash_is_valid($password, $hash) { return (crypt($password, $hash) == $hash);}

    Working test with above PHP functions:

    echo $password = 'secret';echo '<br /><br />';echo $hash = create_hash($password);echo '<br /><br />';echo 'Should be true: ';$valid1 = hash_is_valid($password, $hash);var_dump($valid1); // outputs "bool(true)"echo '<br /><br />';echo 'Should be false: ';$valid2 = hash_is_valid('wrong_pass', $hash);var_dump($valid2); // outputs "bool(false)"echo '<br /><br />';

    Javascript Version (broken)

    Here's what I've got so far, but it isn't quite there

    function hash_is_valid(password, hash, cb) {    // Hash Format:    // $[algorithm]$[number_of_rounds]$[salt]$[hashed_password]    let hashParts = hash.split('

    javascript based on answer to SO question How to validate Symfony2 sha512 passwords using nodejs

    The javascript version is using some test values:

    password: secret

    hash: $6$rounds=1234$56ab50921c460$P4bgd3kMX2xyWJTDOYAdow.jsXiS2TARUJW4BXifgm4czraOIDFLqZ5Ii50GLIKwYTjWwN6WrtG82omQes0cK0

  • Objective C SHA512 hash of two NSData

    Here is a Java code, which computes SHA512 hash of a byte array with salt:

    %%%~COMPRESS~PRE~12~%%%

    In Objective C, I use this algorithm for compute the hash of an NSData:

    %%%~COMPRESS~PRE~13~%%%

    This works perfectly, computes the same hash, as the Java code, if I use the same single data (i.e. the salt is nil in the Java code). The problem is that, if I want to computes hash of two NSData, i.e. there is a salt (the second parameter in the Java code is not nil). You can see that in the Java code, if the salt is not null, it performs an update, and then call the digest method. Somewhere I read that, this operation is equal with merging the two byte array (the data and salt arrays with System.arraycopy), and call the digest on the result array. However, if I do this in Objective C (with NSMutableData appendData method), I don't get the same result. How can I fix this? I can see in the CommonDigest class, there are similar methods, but I don't know, how can I use these...I think of these methods:

    %%%~COMPRESS~PRE~14~%%%

    So I would like to create a method like this:

    %%%~COMPRESS~PRE~15~%%%
  • Cookies

    Please note that by viewing our site you agree to our use of cookies (see Privacy for details). You will only see this message once.

    ' ) console.log(hashParts) let salt = hashParts[3] let numRounds = parseInt(hashParts[2].substr(7)) // from string like rounds=1234 let originalHashResult = hashParts[4] let salted = password + '{' + salt + '}' let processedHash = crypto.createHash('sha512').update(salted, 'utf-8'); for (let i = 1; i < numRounds ; i++) { processedHash = crypto.createHash('sha512').update(processedHash.digest('binary') + salted); } processedHash = processedHash.digest('base64') // Capture the result let hashVerified = (processedHash === originalHashResult) // Call the callback with the result cb(hashVerified)}hash_is_valid('secret', '$6$rounds=1234$56ab50921c460$P4bgd3kMX2xyWJTDOYAdow.jsXiS2TARUJW4BXifgm4czraOIDFLqZ5Ii50GLIKwYTjWwN6WrtG82omQes0cK0', (passed) => { console.log((passed) ? 'password is good' : 'password is no good')})

    javascript based on answer to SO question How to validate Symfony2 sha512 passwords using nodejs

    The javascript version is using some test values:

    password: secret

    hash: $6$rounds=1234$56ab50921c460$P4bgd3kMX2xyWJTDOYAdow.jsXiS2TARUJW4BXifgm4czraOIDFLqZ5Ii50GLIKwYTjWwN6WrtG82omQes0cK0

  • Objective C SHA512 hash of two NSData

    Here is a Java code, which computes SHA512 hash of a byte array with salt:

    private static String DIGEST_ALGORITHM = "SHA-512";    public static byte[] getHash(final byte[] data, final byte[] salt) throws NoSuchAlgorithmException{    final MessageDigest md = MessageDigest.getInstance(DIGEST_ALGORITHM);    md.reset();    if (salt != null)    {        md.update(salt);    }    return md.digest(data);

    In Objective C, I use this algorithm for compute the hash of an NSData:

    @implementation NSData (CommonDigest)- (NSData *) SHA512Hash {unsigned char hash[CC_SHA512_DIGEST_LENGTH];(void) CC_SHA512( [self bytes], (CC_LONG)[self length], hash );return ( [NSData dataWithBytes: hash length: CC_SHA512_DIGEST_LENGTH] );}

    This works perfectly, computes the same hash, as the Java code, if I use the same single data (i.e. the salt is nil in the Java code). The problem is that, if I want to computes hash of two NSData, i.e. there is a salt (the second parameter in the Java code is not nil). You can see that in the Java code, if the salt is not null, it performs an update, and then call the digest method. Somewhere I read that, this operation is equal with merging the two byte array (the data and salt arrays with System.arraycopy), and call the digest on the result array. However, if I do this in Objective C (with NSMutableData appendData method), I don't get the same result. How can I fix this? I can see in the CommonDigest class, there are similar methods, but I don't know, how can I use these...I think of these methods:

    extern int CC_SHA512_Init(CC_SHA512_CTX *c);extern int CC_SHA512_Update(CC_SHA512_CTX *c, const void *data, CC_LONG len);extern int CC_SHA512_Final(unsigned char *md, CC_SHA512_CTX *c);extern unsigned char *CC_SHA512(const void *data, CC_LONG len, unsigned char *md);

    So I would like to create a method like this:

    @implementation NSData (CommonDigest)- (NSData *)SHA512HashWithSalt:(NSData *)salt {...}
  • Cookies

    Please note that by viewing our site you agree to our use of cookies (see Privacy for details). You will only see this message once.

    '