Hi I would like to simulate dovecot's dovecotpw with a perl script I tried / used use Crypt::SaltedHash; my $csh = Crypt::SaltedHash->new(algorithm => 'SHA-1'); $csh->add($passwd_string); my $salted = $csh->generate; also use Digest::SHA1; use MIME::Base64; $ctx = Digest::SHA1->new; $ctx->add($passwd_string); $ctx->add('salt'); my $salted = '{SSHA}' . encode_base64($ctx->digest . 'salt' ,''); But it doesnt work. Basically what im doing is authenticating against a mysql db. If i do a dovecotpw -s SSHA -p password and update the DB, then the mail client authenticates perfectly. If anyone can help, it would be most appreciated. Kind Regards Brent Clark
On Sat, 2008-03-08 at 11:27 +0200, Brent Clark wrote:> use Digest::SHA1; > use MIME::Base64; > $ctx = Digest::SHA1->new; > $ctx->add($passwd_string); > $ctx->add('salt'); > my $salted = '{SSHA}' . encode_base64($ctx->digest . 'salt' ,'');This looks correct, and it also worked when I tried it. $passwd_string = "pass" produces: {SSHA}EfVjnyJSUVXLC0NXPuQhKDjHjYdzYWx0 Which worked just fine when logging in. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://dovecot.org/pipermail/dovecot/attachments/20080308/7264bd5b/attachment-0002.bin>
Thanks Timo Ill try again. Regards Brent Clark On Sat, Mar 8, 2008 at 11:52 AM, Timo Sirainen <tss at iki.fi> wrote:> On Sat, 2008-03-08 at 11:27 +0200, Brent Clark wrote: > > > use Digest::SHA1; > > use MIME::Base64; > > $ctx = Digest::SHA1->new; > > $ctx->add($passwd_string); > > $ctx->add('salt'); > > my $salted = '{SSHA}' . encode_base64($ctx->digest . 'salt' ,''); > > This looks correct, and it also worked when I tried it. > > $passwd_string = "pass" produces: > > {SSHA}EfVjnyJSUVXLC0NXPuQhKDjHjYdzYWx0 > > Which worked just fine when logging in. > >