-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdoorlockd-passwd
More file actions
executable file
·40 lines (30 loc) · 988 Bytes
/
doorlockd-passwd
File metadata and controls
executable file
·40 lines (30 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
"""
Doorlockd -- Binary Kitchen's smart door opener
Copyright (c) Binary Kitchen e.V., 2018
Author:
Ralf Ramsauer <ralf@binary-kitchen.de>
This work is licensed under the terms of the GNU GPL, version 2. See
the LICENSE file in the top-level directory.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
"""
import getpass
import hashlib
import uuid
import sys
if len(sys.argv) != 3:
print('Usage: %s db username' % sys.argv[0])
quit(-1)
username = sys.argv[2]
try:
password = getpass.getpass()
except Exception as error:
print('ERROR', error)
quit(-1)
salt = uuid.uuid4().hex
password = hashlib.sha256(salt.encode() + password.encode()).hexdigest() + ':' + salt
with open(sys.argv[1], 'a') as file:
file.write('%s %s\n' % (username, password))