标签:md5 href log bsp html word lap ide import
import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import sun.misc.BASE64Encoder; public class SimpleMD5Example { public static String EncoderByMd5(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException{ MessageDigest md5=MessageDigest.getInstance("MD5"); BASE64Encoder base64en = new BASE64Encoder(); String newstr=base64en.encode(md5.digest(str.getBytes("utf-8"))); return newstr; } public static void main(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); } }
Openldap的配置文件:
https://www.cnblogs.com/lijingcheng/p/4454802.html
SimpleMD5Example (OpenLdap加密MD5算法的JAVA实现)
标签:md5 href log bsp html word lap ide import
原文地址:http://www.cnblogs.com/littlehb/p/7892349.html