Skip to content

Commit 74543c7

Browse files
committed
First commit
0 parents  commit 74543c7

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Enpass To PassLocker
2+
3+
Recently I switched from [Enpass](http://enpass.io/) to [PassLocker](http://innovationbox.com/passlocker/), because PassLocker has a simple, but usefull feature — it is located in your tray and always available on simple hotkey combination.
4+
5+
But I had almost 100 entries in Enpass and didn't want to transfer them manually. So I decided to write a converter from Enpass txt export to PassLocker csv import.
6+
7+
## Usage
8+
9+
Export your database from Enpass in txt format. Open terminal, run `python3 converter.py` with your file as argument. Then grab a `export.csv` file and import it to PassLocker.
10+
11+
## TODO
12+
13+
* Line-breaks in notes
14+
* python 2
15+
* Tests

converter.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import csv
2+
import sys
3+
4+
csvFile = open('export.csv', 'w')
5+
csvWriter = csv.writer(csvFile, quoting=csv.QUOTE_MINIMAL)
6+
csvWriter.writerow(['title', 'username', 'password', 'notes'])
7+
8+
importSocket = open(sys.argv[1], 'r')
9+
importFile = importSocket.readlines()
10+
importSocket.close()
11+
12+
# Concatenate strings
13+
myList = []
14+
temp = ''
15+
16+
for line in importFile:
17+
if line != '\n':
18+
temp = temp + line
19+
elif temp != '':
20+
myList.append(temp)
21+
temp = ''
22+
if temp != '':
23+
myList.append(temp)
24+
25+
# Create entry
26+
def constructLine(splittedItem):
27+
entry = []
28+
notes = ''
29+
withoutUsername = True
30+
withoutPassword = True
31+
usernameAsEmail = False
32+
33+
# Try to find `Username`
34+
for line in splittedItem:
35+
if line.startswith('Username'):
36+
withoutUsername = False
37+
entry.append(line.replace('Username ', ''))
38+
# If there is no `Username` field — try to find `E-Mail` and use it as `Username`
39+
if withoutUsername:
40+
for line in splittedItem:
41+
if (line.startswith('E-Mail') or line.startswith('Email') or line.startswith('E-mail')):
42+
withoutUsername = False
43+
usernameAsEmail = True
44+
entry.append(line.replace('E-Mail ', '').replace('Email ', '').replace('E-mail', ''))
45+
# If there is no `E-Mail` — field is filled with `none`
46+
if withoutUsername:
47+
entry.append('none')
48+
# Try to find `Password`
49+
for line in splittedItem:
50+
if line.startswith('Password'):
51+
withoutPassword = False
52+
entry.append(line.replace('Password ', ''))
53+
# If there is no `Password` — field is filled with `none`
54+
if withoutPassword:
55+
entry.append('none')
56+
# Everything else goes to `notes` section
57+
for line in splittedItem:
58+
if (not line.startswith('Password') and not line.startswith('Username')) and not ((line.startswith('E-Mail') or line.startswith('Email') or line.startswith('E-mail')) and usernameAsEmail):
59+
notes += line.replace('Url ', '').replace('E-Mail ', '').replace('Email ', '').replace('E-mail', '')
60+
entry.append(notes)
61+
return entry
62+
63+
# Iterate array, close file
64+
for item in myList:
65+
splittedItem = item.split('\n')
66+
# First entry always a name
67+
name = splittedItem.pop(0)
68+
csvWriter.writerow([name] + constructLine(splittedItem))
69+
70+
csvFile.close()

test.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
vk
2+
3+
Password 231
4+
Url http://vk.com/
5+
6+
7+
Facebook
8+
Username xxx
9+
Password qwerty
10+
11+
Url http://facebook.com/
12+
13+
14+
Twitter
15+
Username xxx
16+
Password 123123123
17+
18+
Url http://twitter.com/

0 commit comments

Comments
 (0)