code: function _sha512crypt_intermediate(password, salt) {
      var digest_a = rstr_sha512(password + salt);
      var digest_b = rstr_sha512(password + salt + password);
      var key_len = password.length;
  
      // extend digest b so that it has the same size as password
      var digest_b_extended = _extend(digest_b, password.length);
  
      var intermediate_input = password + salt + digest_b_extended;
      for (cnt = key_len; cnt > 0; cnt >>= 1) {
          if ((cnt & 1) != 0)
              intermediate_input += digest_b
          else
              intermediate_input += password;
      }
      var intermediate = rstr_sha512(intermediate_input);
  
      return intermediate;
  }
docs: steps 1-12