recipe-578431.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:code 作者: ActiveState 项目源码 文件源码
def main(argv):

    if len(argv) != 1:
        sys.exit('Usage: pass_auth3.py <file_name>')

    print '\nPassword Request Program v.04\n'

    try:
        file_conn = open(sys.argv[1])
        password = file_conn.readline()[:-1]
        file_conn.close()
    except:
        sys.exit('There was a problem reading the file!')

    pass_try = 0 
    x = 3

    while pass_try < x:
        user_input = hashlib.sha224(getpass.getpass('Please Enter Password: ')).hexdigest()
        if user_input != password:
            pass_try += 1
            print 'Incorrect Password, ' + str(x-pass_try) + ' more attempts left\n'
        else:
            pass_try = 4

    if pass_try == x and user_input != password:
        sys.exit('Incorrect Password, terminating... \n')

    print 'User is logged in!\n'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号