Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Blockchain lesson
#1
Hello together, today im coming with a special kind of homework. We building a own blockchain on a webserver of my university and i need some help or better ideas then mine.

First of all i would like to show you what is going on and then my code. The ones i marked black or my other students which i censored because of privacy reasons.

The current blockchain looks like this:

https://ibb.co/nLnQMyZ

The problem is the next hash must be a factor of 2 smaller then the last hash and the hash is based on : SHA256(Random Number|| Last Hash || Name)

Allowed are UpperCase, LowerCase and Digits.

My actual try looks like this:
import hashlib
from itertools import product
import string
import random
from multiprocessing import Process

oldHash = '0000000000848e74198ed25b6bba286614c479063dc5b4e2dd20e8e800e27e70'
name = 'Censored'
oldSize = int(oldHash, 16)/2

def go1():
    passwords = string.ascii_lowercase[::-1] + string.ascii_uppercase[::-1] + string.digits[::-1]
    print("Start 1")
    for i in range(14, 15):
        for j in product(passwords, repeat=i):
            # print(j)
            # break
            toHash = str(j)+oldHash+name
            newHash = hashlib.sha256(toHash.encode())
            newSize = int(newHash.hexdigest(), 16)
            if oldSize > newSize:
                print('Found')
                print(j)
                break
            
def go2():
    passwords = string.ascii_uppercase[::-1] + string.ascii_lowercase[::-1] + string.digits[::-1]
    print("Start 2")
    for i in range(13, 14):
        for j in product(passwords, repeat=i):
            #print(j)
            #break;
            toHash = str(j)+oldHash+name
            newHash = hashlib.sha256(toHash.encode())
            newSize = int(newHash.hexdigest(), 16)
            if oldSize > newSize:
                print('Found')
                print(j)
                break
def go3():
    print("Start 3")
    passwords = string.digits[::-1] + string.ascii_uppercase[::-1] + string.ascii_lowercase[::-1]
    for i in range(15, 16):
        for j in product(passwords, repeat=i):
            #print(j)
            #break;
            toHash = str(j)+oldHash+name
            newHash = hashlib.sha256(toHash.encode())
            newSize = int(newHash.hexdigest(), 16)
            if oldSize > newSize:
                print('Found')
                print(j)
                break
def go4():
    print("Start 4")
    passwords = string.digits[::-1] + string.ascii_lowercase[::-1] + string.ascii_uppercase[::-1]
    for i in range(13, 14):
        for j in product(passwords, repeat=i):
            #print(j)
            #break;
            toHash = str(j)+oldHash+name
            newHash = hashlib.sha256(toHash.encode())
            newSize = int(newHash.hexdigest(), 16)
            if oldSize > newSize:
                print('Found')
                print(j)
                break    
def go5(): 
    print("Start 5")
    passwords = string.ascii_uppercase[::-1] + string.digits[::-1] + string.ascii_lowercase[::-1]
    for i in range(13, 14):
        for j in product(passwords, repeat=i):
            #print(j)
            #break;
            toHash = str(j)+oldHash+name
            newHash = hashlib.sha256(toHash.encode())
            newSize = int(newHash.hexdigest(), 16)
            if oldSize > newSize:
                print('Found')
                print(j)
                break    
def go6(): 
    print("Start 6")
    passwords = string.ascii_lowercase[::-1] + str(random.randint(10000000000000, 100000000000000)) + string.ascii_uppercase[::-1]
    for i in range(13, 14):
        for j in product(passwords, repeat=i):
            #print(j)
            #break;
            toHash = str(j)+oldHash+name
            newHash = hashlib.sha256(toHash.encode())
            newSize = int(newHash.hexdigest(), 16)
            if oldSize > newSize:
                print('Found')
                print(j)
                break

def go7():
    print("Start 7")
    passwords = str(random.randint(10000000000000, 100000000000000)) + string.ascii_uppercase[::-1] + string.ascii_lowercase[::-1]
    for i in range(14, 15):
        for j in product(passwords, repeat=i):
            #print(j)
            #break;
            toHash = str(j)+oldHash+name
            newHash = hashlib.sha256(toHash.encode())
            newSize = int(newHash.hexdigest(), 16)
            if oldSize > newSize:
                print('Found')
                print(j)
                break

def main():
    p1 = Process(target=go1)
    p2 = Process(target=go2)
    p3 = Process(target=go3)
    p4 = Process(target=go4)
    p5 = Process(target=go5)
    p6 = Process(target=go6)
    p7 = Process(target=go7)
    p1.start()
    p2.start()
    p3.start()
    p4.start()
    p5.start()
    p6.start()
    p7.start()

if __name__ == '__main__':
    main()
    print("Started...")
As you can see im trying to compare the hashes on base 16 with multiple processes in different ranges. The problem is after hours of hours im not getting any result. Maybe some of you know a better way then mine. Thx in forward!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020