* 지원 알고리즘
Algorithm Name | Description |
---|---|
MD2 | The MD2 message digest algorithm as defined in RFC 1319. |
MD5 | The MD5 message digest algorithm as defined in RFC 1321. |
SHA-1 SHA-224 SHA-256 SHA-384 SHA-512 | Hash algorithms defined in the FIPS PUB 180-4. Secure hash algorithms - SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 - for computing a condensed representation of electronic data (message). When a message of any length less than 2^64 bits (for SHA-1, SHA-224, and SHA-256) or less than 2^128 (for SHA-384 and SHA-512) is input to a hash algorithm, the result is an output called a message digest. A message digest ranges in length from 160 to 512 bits, depending on the algorithm. |
- 참조 : https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#MessageDigest
public static String getMDString(String str, String algorithm) {
String temp = "";
try{
MessageDigest md = MessageDigest.getInstance(algorithm);
md.update(str.getBytes());
byte byteData[] = md.digest();
StringBuffer sb = new StringBuffer();
for(int i = 0 ; i < byteData.length ; i++){
sb.append(Integer.toString((byteData[i]&0xff) + 0x100, 16).substring(1));
}
temp = sb.toString();
}catch(NoSuchAlgorithmException e){
e.printStackTrace();
temp = null;
}
return temp;
}
'Android > etc' 카테고리의 다른 글
TextView 특수문자 개행 및 justify (0) | 2018.10.18 |
---|---|
다중 언어 및 해상도를 위한 리소스 폴더명 (0) | 2018.10.12 |
Kakao REST API 로컬 연동 (1) | 2018.09.14 |
화면 회전을 센서로 체크하기. (0) | 2018.05.17 |
Android VLC Compile (0) | 2018.02.06 |