How to resolve the algorithm Parallel brute force step by step in the BaCon programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Parallel brute force step by step in the BaCon programming language

Table of Contents

Problem Statement

Find, through brute force, the five-letter passwords corresponding with the following SHA-256 hashes: Your program should naively iterate through all possible passwords consisting only of five lower-case ASCII English letters. It should use concurrent or parallel processing, if your language supports that feature. You may calculate SHA-256 hashes by calling a library or through a custom implementation. Print each matching password, along with its SHA-256 hash. Related task: SHA-256

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Parallel brute force step by step in the BaCon programming language

Source code in the bacon programming language

PRAGMA INCLUDE 
PRAGMA LDFLAGS -lcrypto

OPTION MEMTYPE unsigned char

LOCAL buffer[32], passwd[5] TYPE unsigned char
LOCAL result TYPE unsigned char*
LOCAL a,b,c,d,e TYPE NUMBER

DATA "3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b", "74e1bb62f8dabb8125a58852b63bdf6eaef667cb56ac7f7cdba6d7305c50a22f", "1115dd800feaacefdf481f1f9070374a2a81e27880f187396db67958b207cbad"

WHILE TRUE

    READ secret$
    IF NOT(LEN(secret$)) THEN BREAK

    FOR i = 0 TO 31
        buffer[i] = DEC(MID$(secret$, i*2+1, 2))
    NEXT

    FOR a = 97 TO 122
        FOR b = 97 TO 122
            FOR c = 97 TO 122
                FOR d = 97 TO 122
                    FOR e = 97 TO 122
                        passwd[0] = a
                        passwd[1] = b
                        passwd[2] = c
                        passwd[3] = d
                        passwd[4] = e

                        result = SHA256(passwd, 5, 0)

                        FOR i = 0 TO SHA256_DIGEST_LENGTH-1
                            IF PEEK(result+i) != buffer[i] THEN BREAK
                        NEXT
                        IF i = SHA256_DIGEST_LENGTH THEN
                            PRINT a,b,c,d,e,secret$ FORMAT "%c%c%c%c%c:%s\n"
                            BREAK 5
                        END IF
                    NEXT
                NEXT
            NEXT
        NEXT
    NEXT
WEND


  

You may also check:How to resolve the algorithm Narcissist step by step in the zkl programming language
You may also check:How to resolve the algorithm Write float arrays to a text file step by step in the Yabasic programming language
You may also check:How to resolve the algorithm Regular expressions step by step in the Groovy programming language
You may also check:How to resolve the algorithm Execute a system command step by step in the SQL PL programming language
You may also check:How to resolve the algorithm Euler's sum of powers conjecture step by step in the Wren programming language