#!/bin/bash
cat <<end
All passwords are generated twice. If both are equal, 
the scheme does NOT use a salt.

In ldif syntax use either:

userPassword: {SSHA}2kleHu61nroaBkjRbw5/mT3JDQr/CLKz
or the base64 encoded version
userPassword:: e1NTSEF9RndkTDkxVitzclFOTVJzR003dHNQMFptWGhySU1KVSs=

for a SSHA password. 

And now, all password hashes for the secret: $1

end

export schemes="CLEARTEXT MD5 SMD5 SHA SSHA CRYPT"

for sch in $schemes ; do
	echo 'scheme: {'$sch'}'
	echo -n $(/usr/sbin/slappasswd -h '{'$sch'}' -s $1)  &&echo
	echo -n $(/usr/sbin/slappasswd -h '{'$sch'}' -s $1)  &&echo
	echo -n $(/usr/sbin/slappasswd -h '{'$sch'}' -s $1)|base64  &&echo
	#echo

done

echo 'scheme: {CRYPT} (MD5 based)'
echo -n $(/usr/sbin/slappasswd -c '$1$%.8s' -s $1)  &&echo
echo -n $(/usr/sbin/slappasswd -c '$1$%.8s' -s $1)  &&echo
echo -n $(/usr/sbin/slappasswd -c '$1$%.8s' -s $1)|base64  &&echo
