Python Forum
how can I generate a password in hashlib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how can I generate a password in hashlib
#15
yes I have tried to make the question shorter,

anyway here is the final code which I have a problem to write it out in that order which I have said:
#csvfilecontain:
   #danial,99b057c8e3461b97f8d6c461338cf664bc84706b9cc2812daaebf210ea1b9974
   #elham,85432a9890aa5071733459b423ab2aff9f085f56ddfdb26c8fae0c2a04dce84c
import csv
import itertools
from collections import OrderedDict
import hashlib

with open ('code.csv', 'r') as input_file_name:
    reader=csv.reader(input_file_name)
    key=[]
    val1=[]
    for row in reader:
        name = row[0]
        val=[str(num) for num in row[1:]]
        key.append(name)
        val1.append(val)
        value = list(itertools.chain.from_iterable(val1)) #making a simple list from list of list in value
        value=[str(i) for i in value]
    #print(key)
    dict_csv = dict(zip(key, value))  #making a dictionary from the csv file
#print(dict_csv)
listval=[]
for item in dict_csv.values():
    #print(item)
    listval.append(item) 
#print(listval)

rainbow_dict = {}
for i in range(1000, 10000): # note you need upper end to be 10000 in odrder to include 9999
    my_hash = hashlib.sha256(str(i).encode()).hexdigest()
    rainbow_dict[my_hash] = i
#print(rainbow_dict)
list1=[k for k,v in dict_csv.items() if v in listval]
#print(list1)
list2=[v for k,v in rainbow_dict.items() if k in listval]
#print(list2)
####
list3 = [ item for pair in zip(list1, list2 + [0]) for item in pair]
#print(list3)
data=[]
for item in list3:
    #data=[]
    l3=[]
    l3.append(item)
    print(l3)
    data.append(str(item))
print(data)
esm=data[::2]
#print(esm)
pas=data[1::2]

    
with open('code.csv', 'w', newline='') as output_file_name:
        writer = csv.writer(output_file_name)
        for i in range(0,len(esm)):
            dataf=[]
            #print('{},{}'.format(esm[i], pas[i]))
            dataf.append(('{},{}'.format(esm[i], pas[i])))
            writer.writerows(dataf)
        output_file_name.close()
Reply


Messages In This Thread
RE: how can I generate a password in hashlib - by go127a - May-14-2019, 12:47 PM
writing on csv file problem, python - by go127a - May-14-2019, 12:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] How to crack hash with hashlib Milan 0 1,582 Mar-09-2023, 08:25 PM
Last Post: Milan
  Python3 hashlib ogautier 1 1,652 Mar-28-2022, 04:42 AM
Last Post: snippsat
  Confusion about Hashlib Vysero 2 3,115 Jun-25-2018, 04:05 PM
Last Post: DeaD_EyE
  Using SHA3 (keccak) from Hashlib CryptoFlo 0 7,978 Mar-14-2018, 10:56 AM
Last Post: CryptoFlo

Forum Jump:

User Panel Messages

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