1
0
Fork 0

- added password checking

- added command line option --mkpasswd to class argparser to hash a password
- added a method to generate a SHA512-hash to asrc-server.py
This commit is contained in:
fanir 2013-06-25 11:51:19 +02:00
parent 25d3344104
commit 4259e5836b
4 changed files with 29 additions and 9 deletions

View file

@ -74,4 +74,9 @@ class argparser:
"--encoding",
help = "encoding to be used when communicating with clients")
parser.add_argument(
"--mkpasswd",
action = "store_true",
help = "encode a password with SHA512")
return parser.parse_args()

View file

@ -4,12 +4,14 @@
# for protocol version 0.2.20130617
#
import hashlib
class auth:
passwd = ""
def init(password):
#from Crypto.Hash import Hash
import hashlib
global passwd
passwd = password
@ -19,5 +21,12 @@ class auth:
"""
checks a given password
"""
if hashlib.sha512(bytearray(incpass)).hexdigest() == passwd: return True
#return hashlib.sha512(incpass).hexdigest()
if hashlib.sha512(incpass).hexdigest() == passwd: return True
else: return False
def mkpasswd(incpass):
"""
encodes a password with SHA512
"""
return hashlib.sha512(incpass).hexdigest()

View file

@ -6,7 +6,7 @@
from .statuscodes import statuscodes
from .auth import auth
#from .auth import auth
class comm:
@ -29,10 +29,7 @@ class comm:
protocol_version = ProtocolVersion
verbosity = Verbosity
auth.init(Password)
def authenticate():
pass
#auth.init(Password)
# builds an header
def header(CodeList, AdditionalHeaderLines = ""):