I’m trying to find some passwords using the Rainbow method. I have a CSV file containing people’s names and their hashed passwords using SHA-256. I have to retrieve the original passwords which are four-digit numbers [1000-9999].
The CSV file:
iliya,cfa8624c2d1e3c8c89316808b45ce942770e5ef9cd845dfd74baf4a616aa6d3a arshia,03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4
my code:
import hashlib
import csv
def hash_password_hack(passwords, new_passwords):
with open (r'password.csv','r', encoding='utf-8') as f:
reader=csv.reader(f)
dict1={}
for row in reader:
dict1[row[1]]=row[0]
dict2={}
for i in range (1000,10000):
hashed_password=hashlib.sha256(str(i).encode('utf-8')).hexdigest()
dict2[hashed_password]=i
for key in dict1:
with open (r'new_passwords.csv', 'w', newline='') as f1:
writer=csv.writer(f1)
password=dict2[key]
name=dict1[key]
writer.writerow([name,password])
amir goodarzi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1