Skip to content
TheChatArchiveThe Chat Archive
Mistralmistral-medium-2505· Mistral AIHugging Face LMArena Human Preference 140K

I try to authenticate with the OBS Studio websocket. It seems like my authorization…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with gpt-4.1-2025-04-14’s answer.
  1. User

    I try to authenticate with the OBS Studio websocket. It seems like my authorization string is wrong. I implemented it based on the documentations but I could not find an explicit testcase to check if my algorithm produces the expected result. I have found a library that does the same but this is node.js and also does not have expicit strings as unit tests for authentication. I copy here both, give me advise My implementation for the browser const te = new TextEncoder(); const hashedSecret = await crypto.subtle.digest( "SHA-256", te.encode( this.password + salt ) ); const b64Secret = btoa( hashedSecret ); const hashedAuthResponse = await crypto.subtle.digest( "SHA-256", te.encode( b64Secret + challenge ) ); const authentication = btoa( hashedAuthResponse );

    the library implementation for node.js const hash = Base64.stringify(sha256(msg + salt))!;

    return Base64.stringify(sha256(hash + challenge))!;
    
  2. Mistral Assistant

    Looking at both implementations, there are a few key differences that could be causing your authentication to fail. Let me analyze them:

    Key Differences:

    1. Base64 Encoding:

      • Your browser implementation uses btoa() which is the browser's built-in base64 encoder.
      • The Node.js implementation uses Base64.stringify() which might handle padding differently.
    2. String Conversion:

      • Your browser implementation converts the password + salt to UTF-8 bytes before hashing.
      • The Node.js implementation might be treating the input differently (depends on what sha256() expects).
    3. Hash Output:

      • Both implementations use SHA-256, but the way the hash is converted to base64 might differ.

    Suggested Fixes:

    1. Use Consistent Base64 Encoding:

      // Instead of btoa, use this more robust base64 encoder
      function base64Encode(buffer) {
        return btoa(String.fromCharCode(...new Uint8Array(buffer)));
      }
      
    2. Modified Browser Implementation:

      async function generateAuthResponse(password, salt, challenge) {
        const te = new TextEncoder();
      
        // First hash: password + salt
        const firstHash = await crypto.subtle.digest(
          "SHA-256",
          te.encode(password + salt)
        );
      
        // Convert to base64
        const b64FirstHash = base64Encode(firstHash);
      
        // Second hash: base64(firstHash) + challenge
        const secondHash = await crypto.subtle.digest(
          "SHA-256",
          te.encode(b64FirstHash + challenge)
        );
      
        // Final base64
        return base64Encode(secondHash);
      }
      
    3. Testing: To verify your implementation, you can:

      • Use known test vectors (if you can find any for OBS WebSocket auth)
      • Compare outputs with the Node.js implementation for the same inputs
      • Check if OBS provides any debug logging for authentication failures

    Common Pitfalls:

    • Make sure you're using the exact same password, salt, and challenge values in both implementations
    • Ensure there are no hidden characters or whitespace in your strings
    • Verify that the salt and challenge are being received correctly from OBS

    If you can share the exact error you're getting from OBS, I might be able to provide more specific guidance. The authentication failure could also be due to other factors like connection timing or protocol version mismatches.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.