Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3672224
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:34:58+00:00 2026-05-19T02:34:58+00:00

I’m trying to login to https://www.interactivebrokers.com/sso/Login using a c# client. There’s a step that

  • 0

I’m trying to login to https://www.interactivebrokers.com/sso/Login using a c# client. There’s a step that involves creating a sha1 hash from the username & password ( https://www.interactivebrokers.com/sso/Templates/javascript/myxyz.js , line 203):

innerHash = CalcSHA1(username + ":" + password);  

this calls ( https://www.interactivebrokers.com/sso/Templates/javascript/sha1.js , line 113)

calcSHA1Blks(str2blks_SHA1(str);

and str2blks_SHA1() is defined ( https://www.interactivebrokers.com/sso/Templates/javascript/sha1.js , line 28) as

/*
 * Convert a string to a sequence of 16-word blocks, stored as an array.
 * Append padding bits and the length, as described in the SHA1 standard.
 */
function str2blks_SHA1(str)
{
  var nblk = ((str.length + 8) >> 6) + 1;
  var blks = new Array(nblk * 16);
  for(var i = 0; i < nblk * 16; i++) blks[i] = 0;
  for(i = 0; i < str.length; i++)
    blks[i >> 2] |= str.charCodeAt(i) << (24 - (i % 4) * 8);
  blks[i >> 2] |= 0x80 << (24 - (i % 4) * 8);
  blks[nblk * 16 - 1] = str.length * 8;
  return blks;
}

I’m not all that familiar with SHA1 stuff, so I can’t tell if what’s in str2blks_SHA1() is standard stuff that is done automatically inside .net’s SHA1CryptoServiceProvider.ComputeHash(), or if it’s something I need to do explicitly. I tried:

SHA1CryptoServiceProvider.ComputeHash(Encoding.UTF8.GetBytes(userName + ":" + password))

using the same username & password in javascript and in .net, and it seems to generate a different result.

Then I tried to port that str2blks_SHA1() function to c#, but I don’t understand how to create an array of bytes (blks) (which SHA1CryptoServiceProvider.ComputeHash() requires), as it seems like each array item in blks could be larger than a byte (just looking at str.length * 8))…

So, is there already some SHA1 implementation that does the same thing as this javascript implementation available? Or if I really do need to implement this myself, how do I port str2blks_SHA1()?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:34:58+00:00Added an answer on May 19, 2026 at 2:34 am

    This JavaScript implementation looks like the standard SHA-1 padding algorithm from RFC 3174. I get the same results (ignoring minor formatting differences) from running:

    // JavaScript
    calcSHA1("username@example.com:p4ssw0rd");
    

    as I do from:

    // C#
    using (SHA1 hash = SHA1.Create())
        Console.WriteLine(BitConverter.ToString(
            hash.ComputeHash(Encoding.ASCII.GetBytes("username@example.com:p4ssw0rd"))));
    

    What data are you supplying and what (different) results are you getting?

    (Note that if your username or password contain non-ASCII characters, I wouldn’t be surprised for the JavaScript to generate a different result than C#, because it doesn’t appear to be doing a proper UTF-8 conversion; specifically, it appears to assume that each character is just one byte.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to loop through a bunch of documents I have to put
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.