code_junkie

Hiding a password in a (python) script

Nov 11th, 2011
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. >>> import base64
  2. >>> print base64.b64encode("password")
  3. cGFzc3dvcmQ=
  4. >>> print base64.b64decode("cGFzc3dvcmQ=")
  5. password
  6.  
  7. >>> 'your string'.encode('base64')
  8. 'eW91ciBzdHJpbmc=n'
  9. >>> _.decode('base64')
  10. 'your string'
  11.  
  12. import netrc
  13.  
  14. # Define which host in the .netrc file to use
  15. HOST = 'mailcluster.loopia.se'
  16.  
  17. # Read from the .netrc file in your home directory
  18. secrets = netrc.netrc()
  19. username, account, password = secrets.authenticators( HOST )
  20.  
  21. print username, password
Add Comment
Please, Sign In to add comment