Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8081207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:39:34+00:00 2026-06-05T16:39:34+00:00

This code comes from: http://code.activestate.com/recipes/577090-file-encryption-using-stream-cipher/ import sys import random if len(sys.argv) != 4: print

  • 0

This code comes from: http://code.activestate.com/recipes/577090-file-encryption-using-stream-cipher/

import sys 
import random 

if len(sys.argv) != 4: 
    print "Usage: encdec_.py longintkey [path]filename1 [path]filename2" 
    sys.exit()   
random.seed(long(sys.argv[1])) # key 
f1 = open( sys.argv[2], "rb") 
bytearr = map (ord, f1.read () ) 
f2 = open( sys.argv[3], "wb" ) 
for i in range(len(bytearr)): 
    f2.write(chr(bytearr[i] ^ random.randint(0, 255))) 
f1.close() 
f2.close() 

Can this code be parallelized using multiprocessing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:39:35+00:00Added an answer on June 5, 2026 at 4:39 pm

    Normally you would break the file into sections and send each section to a separate process for multiprocessing, but that won’t work in this case because you need to generate the random numbers sequentially from the same seed.

    If you were willing to change the encryption algorithm there are a number of alternative ways you could set it up to be able to handle multiple chunks. But a “stream cipher” specifically doesn’t lend itself to that sort of thing easily.

    You could generate the random numbers first and then feed those generated numbers to multiple processes along with their position, but that is more likely to slow you down than to speed you up.

    So I would say “no”, you can’t make it multiprocessing, at least not in a practical way.

    (I’m assuming this is an experiment or a learning exercise and you’re not trying to use this for serious encryption. If you trying to use it for something serious, there are many full-featured encryption library functions to choose from.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code comes from this page: http://pubs.opengroup.org/onlinepubs/009695399/functions/dlsym.html Can you help me understand this? It
So this source code comes free from this website. http://math.hws.edu/javamath/basic_applets/SliderGraph.html It seems to be
This example is taken from the Linux System Programming book, page 88. Code: http://pastebin.com/mEfmHbPP
This code comes from a tutorial so it's not originally my own work. What
I am trying to understand this inline assembly code which comes from _hypercall0 here
I have been using the code in http://opensebj.blogspot.com/2009/04/naudio-tutorial-5-recording-audio.html to record audio. Basically this code:
I am looking at the 'Metronome' sample code from the iOS SDK ( http://developer.apple.com/library/ios/#samplecode/Metronome/Introduction/Intro.html
I am using this code to download a package from server A and put
I am using the Microsoft Translation api (AJAX Version) from http://www.microsofttranslator.com/dev/ I am having
Note: This code actually codes from a tutorial book I'm reading at the moment,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.