コード例 #1
0
ファイル: prompt.py プロジェクト: bidetaggle/upw
def authenticate(user):

    print('\n- 2. Authentication -\n')
    print('\nEmojish: *** [ ' + user.emojish + ' ] ***\n\n')

    # Is this user has a file in .upw/ ?
    if (user.import_profile()):
        print('* A matching profile has been found: ')
        print('\n ' + cfg.get('UPW_DIR') + user.hash)
        print()

    else:
        print('-------------- Welcome to μPassword -------------')
        print('***                                           ***')
        print('***           You are about to create         ***')
        print('***      a new login/master password pair     ***')
        print('***                                           ***')
        print('-------------------------------------------------')
        print()
        print('* If this is what you want, type `confirm` below')
        print()
        print('* If you\'re trying to authenticate with a login')
        print('  you\'ve already made before on this device, you')
        print('  likely mistyped your master password.')
        print('  Just press [Enter] :)')
        print()
        if (input('> ') == 'confirm'):
            create(user)
        else:
            sys.exit(0)
コード例 #2
0
 def import_profile(self):
     try:
         f = open(cfg.get('UPW_DIR') + self.hash, "r", encoding="utf-8")
         self.profile = json.load(f)
         f.close()
         return True
     except OSError:
         return False
コード例 #3
0
 def add_domain(self, domain):
     try:
         self.profile["domains"].index(domain)
         return False
     except ValueError:
         self.profile["domains"].append(domain)
         f = open(cfg.get('UPW_DIR') + self.hash, "w", encoding="utf-8")
         json.dump(self.profile, f, ensure_ascii=False)
         f.close()
         return True
コード例 #4
0
ファイル: prompt.py プロジェクト: bidetaggle/upw
def create(user):
    print('\n* Please confirm the master password you typed')
    print('  before.\n')
    print('* login: '******'* Master Password: '******'login'], MasterPasswordConfirmation)['hash'] == user['hash']):
    if (User(user.login, MasterPasswordConfirmation).hash == user.hash):
        user.create()
        print('\n*** High five ' + user.login + '! ***\n')
        print('* Your encrypted profile has been created:')
        print('\n ' + cfg.get('UPW_DIR') + user.hash + '\n')
    else:
        print('\n* The password doesn\'t match with the first\n  typed in.\n')
        sys.exit(0)
コード例 #5
0
 def get_domains(self):
     f = open(cfg.get('UPW_DIR') + self.hash, "r", encoding="utf-8")
     data = json.load(f)
     f.close()
     return data['domains']
コード例 #6
0
 def create(self):
     f = open(cfg.get('UPW_DIR') + self.hash, "a", encoding="utf-8")
     json.dump(self.profile, f, ensure_ascii=False)
     f.close()