Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda