-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncryptUtil.java
More file actions
40 lines (30 loc) · 797 Bytes
/
Copy pathEncryptUtil.java
File metadata and controls
40 lines (30 loc) · 797 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package codingTest;
import java.security.MessageDigest;
/**
*
* @author hyeokseung.choi
*
* @create 2010. 12. 22.
*
*/
public class EncryptUtil {
public static String getSHA256(String src) {
String SHA = "";
try{
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(src.getBytes("EUC-KR"));
byte[] mdResult = md.digest();
StringBuffer sb = new StringBuffer();
for(int i=0; i < mdResult.length; i++){
sb.append(Integer.toString((mdResult[i]&0xff) + 0x100, 16).substring(1));
}
SHA = sb.toString();
} catch(Exception e) {
return src;
}
return SHA;
}
public static void main(String[] args) {
System.out.println(getSHA256("상호저축은행#067*1*3*215302#김*수#1원#").toUpperCase());
}
}