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

218
Visualizações
How to implement cryptosystem based on Synchronous Stream Cipher using Vue js

I have a pseudo-random number generator which is generating binary number based on a user-supplied polynomial. The method i have used to generate this is LFSR. Now, if I understand correctly, I should load the file and convert it to binary form in order to take every next bit of the read data and use the XOR operation with every bit of the generated key. The problem is that I have no idea how to convert the loaded file to binary in such a way that I can later perform XOR operations on every bit of the file with the key bit. The only think i know is that i should use <input type="file" @change="onFileSelected"/> to load file. I'd appreciate any help from community.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Assuming you have a getKeyBit() function that returns a bit of the key:

const getKeyByte = () => {
  const byte = []

  // Get 8 key bits
  for (let i = 0; i < 8; ++i) {
    byte.push(getKeyBit())
  }

  // Parse the byte string as base 2
  return parseInt(byte.join(''), 2)
}

const encryptFile = (file) => {
  const fileReader = new FileReader()
  fileReader.readAsArrayBuffer(file)

  return new Promise(resolve => {
    fileReader.onload = () => {
      const buffer = new Uint8Array(fileReader.result)
    
      // Resolve the promsie with mapped Uint8Array
      resolve(buffer.map(byte => {
        // XOR each byte with a byte from the key 
        return byte ^ getKeyByte()
      }))
    } 
  })
}

Be sure to await the result:

const encrypted = await encryptFile(file)
about 4 years ago · Juan Pablo Isaza Relatório
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