Professional Documents
Culture Documents
Blockchain Technology I, Summer 2021 Name: Nasar Khan Student ID: 2019514161004 Assignment #2 Due 8/14/2021 25 Points Account. Ans: Done It
Blockchain Technology I, Summer 2021 Name: Nasar Khan Student ID: 2019514161004 Assignment #2 Due 8/14/2021 25 Points Account. Ans: Done It
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
06d90109c8cce34ec0c776950465421e176f08b831a938b3c6e76cb7bee8790b
3. What is the SHA256 for your name? For Example, my name would be written as 刘杰 or Jie Liu。
9026f783f0ca18be4006d413ef8b061338e0096659a4d932bc04daf46863a351
4. Try a string with at least 100 characters and calculate its SHA256. What is the string and what is the
SHA256?
String:
Department_of_computer-science_and_software-engineering_wangjiang_campus_sichuan_university_chengdu_china
SHA256:
976070e5db0337e2097e4bc9fac297f16a3e73b6e0540f13cdaf53a8b57bd617
5. Find 10 numbers to add to the end of your name so the SHA256. Let’s see if you can find one that
has 40 leading zeros out of the 256 bits (how to check this?). Try 10 numbers or your hash has 40
leading zeros, whichever comes first. Use a loop for this part and turn the code in.
Number Hash
Nasar Khan079 809f38be4d13709a6af3c42d95b7a43de507db430de23dc13d370f89e3446006
Nasar Khan141 b58255fa245624d6c730acdcdaa5373b373ed3f570343588151f47534dfe8bca
Nasar Khan255 de05b76c11f5617d2e872397bac6e98c7139e531c763ea937eff5249c0eba85f
Nasar Khan348 79fed1a5b6ba748e0f8aefc0da80725c2fd3a383979c95c335841988b8600212
Nasar Khan433 3a5ea9722a09fb1f4aa6503167f9744f426f26ae8a00be04a7d566df8d02d8f8
Nasar Khan552 68b8f490c9f72f9910f5dfc8f82061cab3a3eace93ee1a6345bdab46f232bea4
Nasar Khan620 597f00f3a3e744eb5ec0e5facd2fed222d607e7a09f3e4b4edfd12a3613d2368
Nasar Khan752 70e312367c41d7a42a499061596b7c2ce5a47ee380f816883f1e6ac3864ae5a5
Nasar Khan892 33c7fdfcb92bf3895295d8a997ee5a45a3f188205aa5c585f7237dd0eb0b908a
Nasar Khan959 97e9aa20c8cadca399b38a066f09cce9baf7ea5536e36ea6728d79fb3393c791
import random
import re
# initializing string
result = hashlib.sha256(name.encode())
n= random.randint(1, 100)
print(n_plus_name)
res = hashlib.sha256(n_plus_name.encode())
SHA_code = res.hexdigest()
print(SHA_code)
str40 = SHA_code[0:40]
x = 1
# print(str40[element])
if re.match("[0]", str40[element]):
print('Condition matched')
++x
if (x > 39):
print(n_plus_name)
print(SHA_code)
print("\r")
or Snapshot in pycharm
import hashlib
import random
import re
# initializing string
name = "Nasar Khan"
n= random.randint(1, 100)
n_plus_name = name +str(i) + str(n)
print(n_plus_name)
res = hashlib.sha256(n_plus_name.encode())
SHA_code = res.hexdigest()
print(SHA_code)
str40 = SHA_code[0:40]
# print(str40)
x = 1
for element in range(0, len(str40)):
# print(str40[element])
if re.match("[0]", str40[element]):
print('Condition matched')
++x
if (x > 39):
print(n_plus_name)
print(SHA_code)
print("\r")
The End