Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

212
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda