Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
672 B
14
Indexable
Never
from hashlib import sha256
import time
import random
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor


def data(val, diff=4):
  su = time.time()
  nonce = 0
  while True:
    s = "test" +str(nonce) + time.ctime()
    hash = sha256(s.encode()).hexdigest()
    if hash.startswith("0"*diff):                                                      print(nonce, diff, hash, time.time()-su)
      break
    nonce += 1

x = "abcdefghjklmnoprsekdufkvkvmd"
diff = [4,5,6]                                                                   with ProcessPoolExecutor(max_workers = 4) as exe:
  exe.map(data, *zip(*[(x[i], random.choice(diff)) for i in range(11)]))