Import Java.io.unsupportedencodingexception;import Java.security.messagedigest;import Java.security.nosuchalgorithmexception;import Sun.misc.BASE64Encoder; Public classSimplemd5example { Public Staticstring EncoderByMd5 (String str) throws NoSuchAlgorithmException, unsupportedencodingexception{Messagedige St MD5=messagedigest.getinstance ("MD5"); Base64encoder Base64en=NewBase64encoder (); String Newstr=base64en.encode (Md5.digest (Str.getbytes ("Utf-8"))); returnNewstr; } Public Static voidMain (string[] args) throws Unsupportedencodingexception, nosuchalgorithmexception {/*slappasswd-h {MD5}-S "secret" {md5}xr4ilozq4pcoq3aq0qbuaq==*/String Passwordtohash="Secret"; String N_MD5=EncoderByMd5 (Passwordtohash); System. out. println (N_MD5); /*slappasswd-h {MD5}-S "dsideal4r5t6y7u" {md5}ydl5jsekvi9avyfiw1pbpw==*/Passwordtohash="dsideal4r5t6y7u"; N_MD5=EncoderByMd5 (Passwordtohash); System. out. println (N_MD5); }}
Configuration file for OpenLDAP:
Https://www.cnblogs.com/lijingcheng/p/4454802.html
Simplemd5example (Java implementation of the OPENLDAP encryption MD5 algorithm)