I am learning python as of right now so I am still new. I have made an encryption system that outputs the initial password, encrypted password, and date to a text file. The method right now is very simple:
now = datetime.now()
date = ('%s/%s/%s %s:%s:%s' % (now.day, now.month, now.year, now.hour, now.minute, now.second))
writePass = finalPass.translate(passSwap)
with open("capec_dictionary.txt", "a") as text_file:
print(initialPass.format(), " - ", writePass.format(), " - ", date, file=text_file)
print("Password has been saved to dictionary.")
The result is as shown:
hi - ******* - 18/9/2015 17:55:15
hello - ********** - 18/9/2015 17:55:20
test - ********** - 18/9/2015 17:55:23
testing - ********** - 18/9/2015 17:55:28
password - ************* - 18/9/2015 17:55:34
passwords - ************** - 18/9/2015 17:55:45
myspecialpassword - ************************ - 18/9/2015 17:55:57
myspecialpass - ******************* - 18/9/2015 17:56:2
imlearningpython - ******************* - 18/9/2015 17:56:15
imlearning - *************** - 18/9/2015 17:56:21
sillypass - ************** - 18/9/2015 17:56:29
lamepass - ************* - 18/9/2015 17:56:38
testcomplete - ****************** - 18/9/2015 17:56:56
test - ********* - 18/9/2015 17:57:0
testing - ************ - 18/9/2015 17:57:6
goodbye - ************ - 18/9/2015 17:57:9
bye - ******** - 18/9/2015 17:57:17
This is really messy and I want to clean in up. First.. can I append something in python to make a header of "Pass" "Encryption" and "date"? Secondly I want to generate code in which it can be better formatted. For example, the longest string to to be five spaces between.
Something like this:
Password Encryption Date
hi ******* 18/9/2015 17:55:15
hello ********** 18/9/2015 17:55:20
test ********** 18/9/2015 17:55:23
testing ********** 18/9/2015 17:55:28
password ************* 18/9/2015 17:55:34
passwords ************** 18/9/2015 17:55:45
myspecialpassword ************************ 18/9/2015 17:55:57
myspecialpass ******************* 18/9/2015 17:56:2
imlearningpython ******************* 18/9/2015 17:56:15
imlearning *************** 18/9/2015 17:56:21
sillypass ************** 18/9/2015 17:56:29
lamepass ************* 18/9/2015 17:56:38
testcomplete ****************** 18/9/2015 17:56:56
test ********* 18/9/2015 17:57:0
testing ************ 18/9/2015 17:57:6
goodbye ************ 18/9/2015 17:57:9
bye ******** 18/9/2015 17:57:17