PHP: How to calculate the SSHA value of a string
Articles may may have files attached at the end of the post
Submitted by chantra on Mon, 02/16/2009 - 23:01
This bit of code allow one to generate SSHA password as accepted by 'ldapmodify' userPassword entry.
unlike SHA, SSHA is using a random seed, increasing the security of your passwords.
These function are based on the explanation provided at OpenLDAP's What are {SHA} and {SSHA} passwords and how do I generate them? page.
- <?php
- function make_ssha_password($password){
- return $hash;
- }
- function ssha_password_verify($hash, $password){
- // Verify SSHA hash
- if ($ohash == $nhash) {
- return True;
- } else {
- return False;
- }
- }
- $encpass = make_ssha_password($argv[1]);
- if(ssha_password_verify($encpass, $argv[1])){
- }else{
- }
- ?>
will produce:
$ php -f ssha.php foobar
Encoded password is: {SSHA}Q7cMTL+eSfOygiBxzrwfpaFhtRyl8JII
Password could be verified
| Attachment | Size |
|---|---|
| ssha.php.txt | 794 bytes |












