have fun making your combo editor :^)
delimiter = ":"
with open("file.txt", "r", encoding='UTF-8')as f:
data = [f"{x}{delimiter}{y.capitalize()}" for x,y in [tuple(i.strip().split(delimiter)) for i in f.readlines()]]
with open("file.txt", "w+", encoding='UTF-8')as f: f.write("\n".join(data))
before:
username:password1
email:password2
after:
username:Password1
email:Password2
So whats going on here?
well, ets break down this crazy list comprehension
data = [tuple(i.strip().split(delimiter)) for i in f.readlines()]
which sets data
to:
[('username', 'Password1'), ('email', 'Password2')]
basically a list of tuples for each combo in the combolist. ("email", "pass")
So, whats a tuple? think of it as a light ordered list of data that can easily be accessed in loops.
All this does line does is splits the data into 2 parts so i can easily edit the second in my next line. Which brings us to the second loop...
data = [f"{x}{delimiter}{y.capitalize()}" for x,y in data]
This this goes through our list of tuples data
, and just joins them with an f string. you could have just as easily done (x + delimiter + (y.capitalize()))
Obviously you will want to create more modules to use in your tool so you can do the same thing while applying different things. E.g. if you wanted to add an ! to the end of a password you could edit that line and add a function in that applies to y
:
import random
addSpecial(y):
return f"{y}{random.choice(["!", "?", "*", "$"])}
f"{x}{delimiter}{addSpecial(y)}"
some other resources:
Tuple unpacking in for loops
Lastly, don't use it yourself to do harm... I know a thing or two because I've seen (or done) a thing or two in that community...
Feel free to contact me via my bio for more information