public/subjects/blockchain/semi-brute
nprimo 4fa5c876a7 docs: run prettify and move h1 to h2 2023-06-09 09:17:48 +01:00
..
README.md docs: run prettify and move h1 to h2 2023-06-09 09:17:48 +01:00

README.md

Semi Brute

Hash functions are used to secure information. A piece of data, for instance a password, is hashed and only its hash is stored. While there is no way to compute on the original information, one can try every possible value. This is called a brute force attack.

Proof of Work algorithms work in a similar manner. Miners hash a block and modify it continuously to obtain a certain value.

We will create an example of this with a function that finds a string which hash starts with a given value.

Instructions

Create a function semiBrute() that takes as argument a target, which is a two characters hexadecimal number, and returns a string which hash sha256 starts with the target.

Usage

solution = semiBrute('e2')
console.log(solution)
// One valid result : 'abcdefghijklmnopqrs'
// You might find other valid solutions as we only check the first two characters

Notions