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

211
Views
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 answers
Answer question

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 Report
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!