Python程序,可以自动排序并在csv文件中用普通密码替换哈希

Python程序,可以自动排序并在csv文件中用普通密码替换哈希,python,csv,text,Python,Csv,Text,我有一个excel文件“ex.csv”,其中有列-散列、Salt、Name,还有一个txt文件“found.txt”,其中有解密的散列。他们的格式是Hash:Salt:Plain_Password我想将Hash从“ex.csv”改为Plain_Password从“found.txt”改为“found.txt”。我想知道,我该怎么做:)我已经编写了一个测试程序,可以将Hash:Salt输出到单独的txt文件中,但它不起作用 Python代码- # File Reads a = open("ex.c

我有一个excel文件“ex.csv”,其中有列-
散列、Salt、Name
,还有一个txt文件“found.txt”,其中有解密的散列。他们的格式是
Hash:Salt:Plain_Password
我想将
Hash
从“ex.csv”改为
Plain_Password
从“found.txt”改为“found.txt”。我想知道,我该怎么做:)我已经编写了一个测试程序,可以将
Hash:Salt
输出到单独的txt文件中,但它不起作用

Python代码-

# File Reads
a = open("ex.csv")
b = open("found.txt")

# Reading contents

ex = a.read()
found = b.read()

# Splitting files by newline

ex_s = ex.split("\n")
found_s = found.split("\n")

# Splitting them into subarrays by splitting them by ','

temp_exsp2 = []
temp_foundsp2 = []

i=0
for item in ex_s:
    temp_exsp2[i] = item[0] # Presumeably here's an error
    i+=1

i=0

for item in found_s:
    temp_foundsp2[i] = item[0] # Same thing here
    i+=1


i=0
z=0 #Used for incrementing found array

FoundArray0 = [] #For line from ex
FoundArray1 = [] #For line from found

while i!=len(ex_s): # Main comparison loop
    for item in temp_foundsp2: # Inner loop for looping through all found file
        j=0
        if item in temp_exsp2[i]:
            FoundArray0[z] = i
            FoundArray1[z] = j
            z+=1
        j+=1
    i+=1 # Go to the next line in the ex.csv


output = open("output.txt","w")

for out in FoundArray0:
    for out2 in FoundArray1:
        output.write(str(ex_s[FoundArray0]) + ":" + str(temp_foundsp2[FoundArray1]))
FoundArray这里是ex.csv和found.txt中的行号(想知道是否有更好的方法;),因为我觉得它不对)它给了我一个错误-
temp_exsp2[I]=item[0]\
索引器:列表分配索引超出范围

ex.csv中的示例:

210ac64b3c5a570e177b26bb8d1e3e93f72081fd,gx0FMxymN,user1
039e8c304c9ada05fd9cc549ac62e178edbfaed6,eVRCBE2OG,user2
found.txt中的示例

f8fa3b3da3fc71e1eaf6c18e4afef626e1fc7fc1:t7e2jlLvs:pass1
bce61cb17c381e11afbcf89ab30ae5cc8276722f:rjCAX5D6K:pass2
也许有一个excel函数可以做到这一点:我不知道。 我是python新手,想知道实现这一点的最佳方法:)
谢谢;)

要拆分由特定delimeter分隔的条目的字符串,可以使用string.split(delimeter)方法

例如:

a='123:456:abc'
a、 拆分(“:”)
>>>['123','456','abc']

您还可以查看pandas DataFrame,它能够加载csv文件,然后让您轻松地操作列以及更多内容

我不想给你一个完整的答案,但如果你还有任何问题,请在评论中提问。