Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
Conduct sha256 operation in BITS mode

I am trying to conduct a hashing operation in BITS mode using Javascript.

The examples below I am trying to hash the following binary string: 0010010011100100

In BITS mode, ASCII '0' is interpreted as 0-bit, ASCII '1' interpreted as 1-bit, and all other characters are ignored. Read more here.

I can obtain the expected output in the command line with echo 0010010011100100 | shasum -a 256 -0, which outputs the expected result (86e89f2cdc1c84f2722cb39341c1888113d61a66f46df75803cfce9d5c9a8637)

However, I am unable to figure out how to get the same output in JS (preferably plain JS with no libraries). I keep getting a "non-BITS mode" result.

Here is what I have so far. This outputs a normal hash (without BITS mode).

const crypto = require('crypto');
function sha256(string) {
  return crypto.createHash('sha256').update(string).digest('hex');
}

Any ideas would be great! Thanks!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!