oracle 存储过程执行java进行密码加密成LDAP方式2

步骤

1.先写 java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sun.misc.BASE64Encoder;


public class PwdToLdap {

public static String ldapSHA(String pwd) {
byte[] md = hexStringTobyteArray(pwd);
return "{SHA}" + (new BASE64Encoder()).encode(md);
}

public static byte[] hexStringTobyteArray(String str) {
if(str == null || str.trim().equals("")) {
return new byte[0];
}


byte[] bytes = new byte[str.length() / 2];
for(int i = 0; i < str.length() / 2; i++) {
String subStr = str.substring(i * 2, i * 2 + 2);
bytes[i] = (byte) Integer.parseInt(subStr, 16);
}
return bytes;
}


}
阅读更多

oracle 存储过程执行java进行密码加密成LDAP方式

步骤

1.先写 java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sun.misc.BASE64Encoder;


public class PwdToLdap {

public static String ldapSHA(String pwd) {
byte[] md = hexStringTobyteArray(pwd);
return "{SHA}" + (new BASE64Encoder()).encode(md);
}

public static byte[] hexStringTobyteArray(String str) {
if(str == null || str.trim().equals("")) {
return new byte[0];
}


byte[] bytes = new byte[str.length() / 2];
for(int i = 0; i < str.length() / 2; i++) {
String subStr = str.substring(i * 2, i * 2 + 2);
bytes[i] = (byte) Integer.parseInt(subStr, 16);
}
return bytes;
}


}
阅读更多