- 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:
parent
25d3344104
commit
4259e5836b
4 changed files with 29 additions and 9 deletions
include
|
@ -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()
|
||||
|
|
|
@ -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()
|
|
@ -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 = ""):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue