PDA

View Full Version : [python] evitare l'uso di password in chiaro


Oceans11
31-05-2013, 12:50
Salve,

tempo fa avevo bisogno di un programma che ad intervalli prestabiliti controllasse diversi account gmail tramite imap. Ho scritto 4 righe in croce di python(2):


def check_mail(username, password):
try:
imap=imaplib.IMAP4_SSL('imap.gmail.com',993)
imap.login(username,password)
imap.select()
unseen=len(imap.search(None, 'UnSeen')[1][0].split())
imap.close()
imap.logout()
return unseen
except:
return False


per pigrizia e semplicità le password (così come gli account) sono hardcoded ed in chiaro.
Vorrei poter salvare le password in modo sicuro su disco oppure, chessò, gmail offre la possibilità di fare login attraverso l'invio di credenziali già hashate?
non ho trovato info a riguardo.

nico159
03-06-2013, 08:39
Ti conviene sfruttare qualcosa come: https://pypi.python.org/pypi/keyring#what-is-python-keyring-lib

Hardware Upgrade Forum Database Error
Database Error Database error
The Hardware Upgrade Forum database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.hwupgrade.it home page, then try to open another page.
  • Click the Back button to try another link.
The www.hwupgrade.it forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.