Today we decided to share a snippet of a code to generate passwords, the password is generated and stored in a database.
This code is complete without dependences, you can modify it to make it more secure and portable, for example encrypt the database just like WhatsApp does, create a front end for reading and writing information from and to the database.
Enough of the mambo jambo here is the code:
# -*- coding: utf-8 -*-
#Python 2.5
import sqlite3 as lite
import datetime
import string
from random import *
print "*"*20,"Password Database","*"*20
site=raw_input("Url of website: ")
username=raw_input("your username: ")
date= datetime.date.today()
characters = string.ascii_letters + string.digits
password = "".join(choice(characters) for x in range(randint(10,16)))
leng=len(password)
con = lite.connect('test.sqlite') # connect to the database
cur = con.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS pasw(site text,username text, password text, date timestamp)") #Create the table and column if it does not exist
cur.execute("INSERT INTO pasw(site,username,password,date) VALUES (?,?,?,?)",(site,username,password,date)) #insert the values
con.commit()
print "Changes saved successfully"
print "Database was Closed Successfully"
print
print "*"*30
print "Displaying Your database Details"
print "*"*30
print
for row in cur.execute("select * from pasw"):
print row[3],row[0],row[1],row[2]
con.close()
Don't forget to comment and share as it's important to us to serve you better.
Wow.. It works like APP algorithm. We can relate it with it can't we?
ReplyDelete