📜 ⬆️ ⬇️

Console application PassKeep

Hello, Habrazhiteli!

How do you keep your passwords? Or do you have one password for all occasions? I used to have it that way! Well, that is almost the case. I had two of them - an identification code and a cunningly wise anagram made up of my mobile phone.

If you are one of those like me, then I ask under the cat.
')
I have long been ripe idea to write something like that. And now, finally, I had a free day and I decided to implement this business.

Action plan

So, what would we like to see:
  1. The program should generate a password based on the url of the resource where we register, for example;
  2. The password must be sufficiently resistant to Brutaforce, that is, contain letters and numbers;
  3. The password should not be stored anywhere, but generated on the fly;
  4. Password must be recoverable.


I imagine this:
  1. After starting the program, you need to enter a password (it can be simple, say 45678);
  2. You must enter a url, for example www.twitter.com ;
  3. We get a 10-digit password, which we use for registration.


How it works?

After entering the password and url, we get their md5 sums, concatenate the strings and get a string of 64 characters. Next, we get the md5-sum of this line and take the first 10 characters - this will be our password. Pretty simple.

Implementation

I really like Python and JavaScript, but since I want to get a console application, I don’t know how to run a JavaScripte program in the console, then we will write on Pythone. Let's start:

import hashlib, sys, re class PassKeep: #,  , ! __password = "" __length = 10 #    10 . url = "" def getMd5(self, string): #   md5  . string = str(string) md5 = hashlib.md5() md5.update(string) return md5.hexdigest() def __init__(self): #,   .   .      . self.__password = self.getMd5(self.__password) self.time = self.getMd5(time.time()) def setUrl(self, url): # url. self.url = self.getMd5(url) return self.url def setPasswd(self, passwd): # . self.__password = self.getMd5(passwd) return self.__password def decrypt(self): # ,   . password = self.__password #   url, url = self.url #    . result = self.getMd5(password + url) #  md5    . passwd_candidate = result[:self.__length] #     10 . #    !   , # ,    ,   n(10)    . #     -   ,     -   ! if (len(re.findall(r'([0-9]+)', passwd_candidate)[0]) + 3 < len(passwd_candidate)): #    return passwd_candidate else: #  ,   . result = "" count = 0 sum = 1 for symbol in passwd_candidate: #     . if (sum < 4): #       ,    . try: #     int,   str (). int_symbol = int(symbol) if (count%2 != 0): #      . print int_symbol result += chr(122 - int_symbol) #   ,          ,     ! sum += 1 count += 1 else: # ,    . result += symbol count += 1 except: #  str       . result += symbol count += 1 else: result += symbol count += 1 return result p = PassKeep() # . passwd = raw_input("Enter passwd \n") #       ! p.setPasswd(passwd) url = raw_input("Enter url, like www.example.com \n") p.setUrl(url) print p.decrypt() #      sys.exit(0) # . 


Launch

Running it is quite simple - save the whole thing to the passkeep.py file and run:
python passkeep.py


Conclusion

I have been using this thing for almost 12 hours. I registered on 5 resources and changed my password on 2. Initially, passwords were generated on a 64-bit processor, now I tried it on an 86-bit one, it seems that the passwords are the same. Well, that's me, just in case.

Oh yes. I also poured this business on Github: clack .

I want to test the whole thing a little more and, if there are no problems, port it to iOS / Android / Chrome Extensions.

I would be very happy constructive comments on the implementation.

Thanks for attention.

UPD:
Thanks to Dark_MX for its additions and thanks to Romansl for finding an extension for chrome.

Source: https://habr.com/ru/post/128707/


All Articles