Commit e0afedf8 authored by Nico Schottelius's avatar Nico Schottelius

create ldap password

Signed-off-by: default avatarNico Schottelius <>
parent 937d5f0d
#! /usr/bin/python
import hashlib
import os
from base64 import urlsafe_b64encode as encode
from base64 import urlsafe_b64decode as decode
def makeSecret(password):
salt = os.urandom(4)
h = hashlib.sha1(password)
return "{SSHA}" + encode(h.digest() + salt)
def checkPassword(challenge_password, password):
challenge_bytes = decode(challenge_password[6:])
digest = challenge_bytes[:20]
salt = challenge_bytes[20:]
hr = hashlib.sha1(password)
return digest == hr.digest()
if __name__ == '__main__':
import sys
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment