Given a LDAP password stored in SHA-1/{SSHA} how would I validate it in erlang.
For example – given the following {SSHA}:
% slappasswd -s myPassword
{SSHA}GEH5kMEQZHYHS95dgr6KmFdg0a4BicBP
%
How would I (in erlang) validate that clear text ‘myPassword’ matches with the hashed value of ‘{SSHA}GEH5kMEQZHYHS95dgr6KmFdg0a4BicBP’.
After some help from others I’ve come up with a routine to do this in Erlang. Following up here to share with others.
First – this link (found in another post) gives functions in other languages doing what I wanted:
The trick was that the ‘ldap {SSHA}’ encoding is a salted-SHA1 hash which is also base64 encoded. So – you must decode it, extract the salt and then use that in the re-encoding of the ‘clear password’ for comparison.
Here is a short Erlang routine which does this:
Given the data in my original post – here’s the output:
Thanx all.
Mike