fork(12) download
  1. #!/usr/bin/env python
  2.  
  3. import random
  4.  
  5. passwd = None
  6.  
  7. while True:
  8. line = raw_input('> ').rstrip('\r\n')
  9.  
  10. # Handle: pass
  11. if line.lower() == 'pass':
  12. print 'Password: {}'.format(passwd)
  13. # For Python <=2.5.6:
  14. #print 'Password: %s' % passwd
  15. # Handle: randompass
  16. elif line.lower() == 'randompass':
  17. passwd = random.randint(10000000, 99999999)
  18. print 'Password generated and stored. Use \'pass\' to retrieve.'
  19. # Handle: exit
  20. elif line.lower() == 'exit':
  21. print 'Exiting.'
  22. break
Success #stdin #stdout 0.02s 10544KB
stdin
pass
randompass
pass
randompass
pass
exit
stdout
> Password: None
> Password generated and stored. Use 'pass' to retrieve.
> Password: 60700793
> Password generated and stored. Use 'pass' to retrieve.
> Password: 21757290
> Exiting.