Skip to content

Commit

Permalink
v1.2 (#2)
Browse files Browse the repository at this point in the history
* update resource path resolution

* update readme
  • Loading branch information
petabite authored Jul 10, 2020
1 parent 3ce14b3 commit 721286d
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*.exe
*.ulokr
.vscode

.DS_Store
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
75 changes: 42 additions & 33 deletions Lokr/Lokr.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/local/bin/python3
"""
██╗ ██████╗ ██╗ ██╗██████╗
██║ ██╔═══██╗██║ ██╔╝██╔══██╗
Expand All @@ -19,21 +20,22 @@
from Crypt import Crypt
from LoginFrame import LoginFrame


class Lokr(tk.Tk):
ver = 1.1
ver = 1.2

def __init__(self):
# init main window
tk.Tk.__init__(self)
self.lokr_file = ''
self.user_file = '.lokrdata/usrs.ulokr'
self.user = ''
self.wm_iconbitmap(self, default=self.resource_path('assets\\closedlock.ico'))
self.logo = tk.PhotoImage(file=self.resource_path('assets\\lock.png'))
self.title('LOKR LOGIN')
self.lokr_file = ""
self.user_file = self.resource_path(".lokrdata/usrs.ulokr")
self.user = ""
self.iconbitmap(self.resource_path("assets/closedlock.ico"))
self.logo = tk.PhotoImage(file=self.resource_path("assets/lock.png"))
self.title("LOKR LOGIN")
self.minsize(350, 200)
plain_text_file = open('.lokrdata/cset.dlokr', 'rb')
cipher_text_file = open('.lokrdata/cpcset.dlokr', 'rb')
plain_text_file = open(self.resource_path(".lokrdata/cset.dlokr"), "rb")
cipher_text_file = open(self.resource_path(".lokrdata/cpcset.dlokr"), "rb")
plain_text = pickle.load(plain_text_file)
cipher_text = pickle.load(cipher_text_file)
plain_text_file.close()
Expand All @@ -48,12 +50,12 @@ def savePassword(self, label, pwd, key):
# appends encrypted pass, key, lbl to user's .lokr file
encrypted_label = self.crypt.encrypt(label, key)
encrypted_password = self.crypt.encrypt(pwd, key)
file = open(self.lokr_file, 'rb')
file = open(self.resource_path(self.lokr_file), "rb")
file.seek(0)
whatsinside = pickle.load(file)
file.close()
whatsinside[encrypted_label] = {str(key): encrypted_password}
file = open(self.lokr_file, 'wb')
file = open(self.resource_path(self.lokr_file), "wb")
pickle.dump(whatsinside, file)
file.close()

Expand All @@ -65,43 +67,44 @@ def editPassword(self, index, label, pwd):

def deletePassword(self, index):
# delete password from user's .lokr
labels = self.parseLokrFile('labels')
file = open(self.lokr_file, 'rb')
labels = self.parseLokrFile("labels")
file = open(self.resource_path(self.lokr_file), "rb")
file.seek(0)
contents = pickle.load(file)
file.close()
del contents[labels[index]]
file = open(self.lokr_file, 'wb')
file = open(self.resource_path(self.lokr_file), "wb")
pickle.dump(contents, file)
file.close()


# USER MANAGEMENT METHODS

def setUserLokrFile(self, username):
# set user's lokr file
self.user = username
for file in os.listdir(os.getcwd() + '\\.lokrdata'):
if file == (self.crypt.encrypt(username, 11) + '.lokr'):
for file in os.listdir(self.resource_path(".lokrdata")):
if file == (self.crypt.encrypt(username, 11) + ".lokr"):
self.lokr_file = ".lokrdata/" + file

def readUsersFile(self):
# reads USR file, returns: decrypted usr info as a dict in format: usr:pwd
file = open(self.user_file, 'rb')
file = open(self.resource_path(self.user_file), "rb")
user_data = pickle.load(file)
file.close()
decrypted_user_data = {}
for user, pwd in user_data.items():
decrypted_user_data[self.crypt.decrypt(user, 7)] = self.crypt.decrypt(pwd, 7)
decrypted_user_data[self.crypt.decrypt(user, 7)] = self.crypt.decrypt(
pwd, 7
)
return decrypted_user_data

def saveUser(self, usr, pwd):
# appends usr and pwd to USR file
file = open(self.user_file, 'rb')
file = open(self.resource_path(self.user_file), "rb")
user_data = pickle.load(file)
file.close()
user_data[self.crypt.encrypt(usr, 7)] = self.crypt.encrypt(pwd, 7)
file = open(self.user_file, 'wb')
file = open(self.resource_path(self.user_file), "wb")
pickle.dump(user_data, file)
file.close()

Expand All @@ -112,12 +115,11 @@ def authenticate(self, usr, pwd):
return True
return False


# LOKR FILE METHODS

def parseLokrFile(self, call):
#reads .lokr, input: call('keys', 'labels, or 'pwds'), returns: requested info as a list
file = open(self.lokr_file, 'rb')
# reads .lokr, input: call('keys', 'labels, or 'pwds'), returns: requested info as a list
file = open(self.resource_path(self.lokr_file), "rb")
file.seek(0)
lokr_data = pickle.load(file)
labels = list(lokr_data.keys())
Expand All @@ -128,39 +130,46 @@ def parseLokrFile(self, call):
keys.append((list(list(lokr_data.values())[k].keys())[0]))
for k, i in enumerate(list(lokr_data.keys())):
pwds.append((list(list(lokr_data.values())[k].values())[0]))
if call == 'keys':
if call == "keys":
return keys
if call == 'labels':
if call == "labels":
return labels
if call == 'pwds':
if call == "pwds":
return pwds

def decryptLokr(self, info):
# decrypts .lokr file, input: info('labels' or 'pwds'), returns: requested info as a list
keys = self.parseLokrFile('keys')
keys = self.parseLokrFile("keys")
labels = self.parseLokrFile("labels")
pwds = self.parseLokrFile("pwds")
newlabels = [self.crypt.decrypt(labels[x], keys[x]) for x in range(len(keys))]
newpwds = [self.crypt.decrypt(pwds[x], keys[x]) for x in range(len(keys))]
if info == 'labels':
if info == "labels":
return newlabels
if info == 'pwds':
if info == "pwds":
return newpwds

def createLokr(self, name):
# creates new .lokr file for user with defaults
file = open('.lokrdata/' + self.crypt.encrypt(name, 11) + '.lokr', 'wb')
pickle.dump({'ExampleLabel':{5:'ExamplePassword'}}, file)
file = open(
self.resource_path(".lokrdata/" + self.crypt.encrypt(name, 11) + ".lokr"),
"wb",
)
pickle.dump({"ExampleLabel": {5: "ExamplePassword"}}, file)
file.close()

# HELPER METHODS

def resource_path(self, relative_path):
# PyInstaller creates a temp folder and stores path in _MEIPASS
current_file_path = __file__
current_file_dir = os.path.dirname(__file__)
# os.path.join(current_file_dir,
try:
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
return os.path.join(current_file_dir, relative_path)


lokr = Lokr()
Binary file modified Lokr/assets/lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 43 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,90 @@
```
██╗ ██████╗ ██╗ ██╗██████╗
██║ ██╔═══██╗██║ ██╔╝██╔══██╗
██║ ██║ ██║█████╔╝ ██████╔╝
██║ ██║ ██║██╔═██╗ ██╔══██╗
███████╗╚██████╔╝██║ ██╗██║ ██║
╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
██╗ ██████╗ ██╗ ██╗██████╗
██║ ██╔═══██╗██║ ██╔╝██╔══██╗
██║ ██║ ██║█████╔╝ ██████╔╝
██║ ██║ ██║██╔═██╗ ██╔══██╗
███████╗╚██████╔╝██║ ██╗██║ ██║
╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
██████╗ █████╗ ███████╗███████╗██╗ ██╗ ██████╗ ██████╗ ██████╗
██╔══██╗██╔══██╗██╔════╝██╔════╝██║ ██║██╔═══██╗██╔══██╗██╔══██╗
██████╔╝███████║███████╗███████╗██║ █╗ ██║██║ ██║██████╔╝██║ ██║
██╔═══╝ ██╔══██║╚════██║╚════██║██║███╗██║██║ ██║██╔══██╗██║ ██║
██║ ██║ ██║███████║███████║╚███╔███╔╝╚██████╔╝██║ ██║██████╔╝
╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝
███╗ ███╗ █████╗ ███╗ ██╗ █████╗ ██████╗ ███████╗██████╗
████╗ ████║██╔══██╗████╗ ██║██╔══██╗██╔════╝ ██╔════╝██╔══██╗
██╔████╔██║███████║██╔██╗ ██║███████║██║ ███╗█████╗ ██████╔╝
██║╚██╔╝██║██╔══██║██║╚██╗██║██╔══██║██║ ██║██╔══╝ ██╔══██╗
██║ ╚═╝ ██║██║ ██║██║ ╚████║██║ ██║╚██████╔╝███████╗██║ ██║
╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝
███╗ ███╗ █████╗ ███╗ ██╗ █████╗ ██████╗ ███████╗██████╗
████╗ ████║██╔══██╗████╗ ██║██╔══██╗██╔════╝ ██╔════╝██╔══██╗
██╔████╔██║███████║██╔██╗ ██║███████║██║ ███╗█████╗ ██████╔╝
██║╚██╔╝██║██╔══██║██║╚██╗██║██╔══██║██║ ██║██╔══╝ ██╔══██╗
██║ ╚═╝ ██║██║ ██║██║ ╚████║██║ ██║╚██████╔╝███████╗██║ ██║
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝
```


# LOKR

![logo](https://raw.githubusercontent.com/BugsForDays/Lokr/master/Lokr/assets/closedlock.ico)

## SecureLocker Improved. A little bit safer. New GUI. Edit and Delete Passwords

### EDITION 1.1
### VERSION 1.2

### Created by [petabite](https://github.com/petabite "To my Github Profile!!!") aka 尸廾工𠃊工尸 乙
----

----
---

---

---

----
## CHANGELOG:
| Release | Changes | Date |
|:-------:|:-------------|:-------:|
|v1.1 | <ul><li>Complete code refactoring</li><li>Fix .exe bugs</li><li>Reorganization under the hood</li></ul>| 8/9/2019
|v1.0 | <ul><li>FIRST RELEASE!!</li></ul> |11/24/2017

## SCREENSHOT:
![screenshot](https://raw.githubusercontent.com/petabite/Lokr/master/images/screenshot.png)
| Release | Changes | Date |
| :-----: | :------------------------------------------------------------------------------------------------------ | :--------: |
| v1.2 | <ul><li>fix resolving resource path bug</li><li>support for running w/o invoking python</li></ul> | 7/9/2020 |
| v1.1 | <ul><li>Complete code refactoring</li><li>Fix .exe bugs</li><li>Reorganization under the hood</li></ul> | 8/9/2019 |
| v1.0 | <ul><li>FIRST RELEASE!!</li></ul> | 11/24/2017 |

## SCREENSHOT:

![screenshot](https://raw.githubusercontent.com/petabite/Lokr/master/images/screenshot.png)

---

## INSTALLATION INSTRUCTIONS:

1. Go to the releases tab in this repo.
2. For Windows: Download the Lokr.exe.zip file

For other systems: Download compatible Source Code for your system.
For other systems: Download the source code

NOTE: Source Code folders contain the Python script for the program. You will need a Python interpreter in order to run.
3. Unzip the folder Lokr/Source Code folder to any location.
4. Create a shortcut if you wish for easier access(Windows only) or [write a script](https://stackoverflow.com/questions/4377109/shell-script-execute-a-python-program-from-within-a-shell-script)

If you downloaded Source Code folders: Run the 'Lokr/Lokr.py' script with your favorite interpreter.
3. Unzip the folder Lokr/Source Code folder to any location.
4. Create a shortcut if you wish for easier access(Windows only) or [write a script](https://stackoverflow.com/questions/4377109/shell-script-execute-a-python-program-from-within-a-shell-script)(Linux) or create an Automator app that runs that script automatically(macOS)
5. Follow 'GETTING STARTED' instructions below.

---

## UPDATE INSTRUCTIONS:

1. Go to releases tab in this repo and click on the latest release.
2. For Windows: Download the Lokr.exe.zip file

For other systems: Download compatible Source Code for your system.

NOTE: Source Code folders contain the Python script for the program. You will need a Python interpreter in order to run.

3. Unzip the folder Lokr/Source Code folder to any location.
4. Move .exe or .py files to your current Lokr folder(the one from your very first installation) and *replace* the old program.
4. Move .exe or .py files to your current Lokr folder(the one from your very first installation) and _replace_ the old program.

NOTE: Be careful to not replace the .lokrdata directory!!

NOTE: Be careful to not replace the .lokrdata directory!!
5. Make sure to create a new shortcut(Windows).

---

## GETTING STARTED:
1. Run python Lokr.py in the Lokr directory(Linux and others) or double click on the Lokr icon(Windows).

1. Run `python3 Lokr.py` in the Lokr directory(macOS/Linux) or double click on the Lokr icon(Windows) or run your Automator app(macOS).
2. Register an account
3. Login with new info
4. Encrypt a new password
Expand All @@ -87,20 +95,25 @@
## TROUBLESHOOTING:

### Problem:

My passwords do not show up!

### Solution:

Make sure the .lokr file associated with your account is in the .lokrdata directory. The .lokrdata directory also has to be in the same directory as the Lokr program.

### Problem:

My username and passwords are incorrect!

### Solution:

First, double check that the username and password info is correct. If that is all correct, make sure that the usrs.ulockr file is in the .lokrdata directory, which should be in the same directory as the Lokr program.

---

### DEFAULT TESTER ACCOUNT:

usrname: c

pwd: c

0 comments on commit 721286d

Please sign in to comment.