Create a dovecot SHA1 digest using bash or python or some other linux command-line tool -


our dovecot , email server authenticate users using sha1 digests. can't change current digest because have many users , don't want have have them re-create passwords.

we easier way create digest put database our users (and create web interface can change themselves).

currently, create digest using linux command:

dovecotpw -s sha1 

we want switch because dovecotpw not scriptable (at least not without using expect or similar). however, i've tried (sha1sum, mysql's sha1, python's hashlib.sha1) produce different dovecotpw command.

below output various commands word: password

dovecotpw -> w6ph5mm5pz8ggiulbpgzg37mj9g= sha1sum -> 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 python hashlib.sha1() -> 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 mysql sha1() -> 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 

so looks dovecot 1 doing things differently. unfortunately, 1 need create.

any idea's how can dovecot sha1 scriptable command?

thanks.

you need base64 encode binary digest format.

>>> import hashlib >>> import base64  >>> p = hashlib.sha1('password') >>> base64.b64encode(p.digest()) 'w6ph5mm5pz8ggiulbpgzg37mj9g=' 

edit: way if you'd prefer terminal/bash script, can

$ echo -n 'password' | openssl sha1 -binary | base64      w6ph5mm5pz8ggiulbpgzg37mj9g= 

also, can tell dovecotpw didn't give hexdigest of hash anymore because has more chars aren't hexidecimal [0-9a-f]. use of characters [a-za-z0-9+/] = ending suggests base64 conversion of hash.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -