encryption - No speedup when using Python multiprocessing for parallel hashing -


i trying figure out why below task, repeatedly rc4 encrypting string, slower when using pool.map(). can see map long-running attack_byte function range(0, 16), slower iteratively calling attack_byte 16 times. there operation in code can't parallelized?

import binascii import base64 import itertools import operator op import os import multiprocessing mp crypto.cipher import arc4  secret_cookie = base64.b64decode("qkugu1vsrsbutybeuklosybzt1vsie9wquxusu5f").decode("utf-8")  def rc4_oracle(request):     rand_key = os.urandom(128)     cipher = arc4.new(rand_key)     ptext = request + secret_cookie      return cipher.encrypt(ptext)  def attack_byte(idx):      chars = {char: 0 char in range(256)}      padding = 'a'*(15 - idx)      in range(2**24):         if % (10**6) == 0:             print("iteration: ", i)          ctext = rc4_oracle(padding)         guess = ctext[15] ^ 0xf0         chars[guess]+= 1      max_char = max(chars.items(), key = op.itemgetter(1))     return chr(max_char[0])  pool = mp.pool(processes = 16) found_cookie = pool.map(attack_byte, range(0, 16))  #for in range(16):     #found_cookie += attack_byte(i) 

note: cryptopals crypto challenges.

i using vsphere vm 24 cores , 64gb of ram.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -