문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 다음 판 | 이전 판 | ||
|
wiki:miscellaneous:md5 [2022/04/18 21:06] emblim98 만듦 |
wiki:miscellaneous:md5 [2023/01/13 18:44] (현재) |
||
|---|---|---|---|
| 줄 18: | 줄 18: | ||
| * 데이터 길이의 조건을 맞추기 위해 부가하여 기록되는 의미 없는 정보 (출처 : 전자용어사전) | * 데이터 길이의 조건을 맞추기 위해 부가하여 기록되는 의미 없는 정보 (출처 : 전자용어사전) | ||
| \\ | \\ | ||
| + | \\ | ||
| + | ===== Class MessageDigest ===== | ||
| + | MessageDigest 클래스는 SHA-1 또는 SHA-256과 같은 Message Digest 알고리즘의 기능을 애플리케이션에 제공합니다.\\ | ||
| + | __**Message Digest**__는 __**임의의 크기를 가진 데이터를 가져와 고정된 길이의 해시값으로 출력하는 안전한 단방향의 해시 함수**__입니다.\\ | ||
| + | (Message digests are secure one-way hash functions that take arbitrary-sized data and output a fixed-length hash value.)\\ | ||
| + | \\ | ||
| + | 모든 Java 플랫폼을 구현하는 것에는 다음의 표준 MessageDigest 알고리즘을 지원해야 합니다.\\ | ||
| + | * MD5 | ||
| + | * SHA-1 | ||
| + | * SHA-256 | ||
| + | 이러한 알로리즘들은 Java Cryptography Architecture Standard Algorithm Name Documentation의[[https:// | ||
| + | \\ | ||
| + | \\ | ||
| + | ===== Class DigestUtils ===== | ||
| + | 일반적인 MessageDigest 작업을 단순화하는 작업입니다. 이 클래스는 변경할 수 없으며, 스레드로부터 안전합니다. 그러나 일반적으로 이 클래스가 생성하는 MessageDigest 인스턴스는 그렇지 않습니다.\\ | ||
| + | \\ | ||
| + | [[https:// | ||
| \\ | \\ | ||
| + | |||
| + | ===== md5Hex ===== | ||
| + | <code java> | ||
| + | public static String md5Hex(String data) | ||
| + | </ | ||
| + | \\ | ||
| + | Calculates the MD5 digest and returns the value as a 32 character hex string.\\ | ||
| + | MD% digest를 계산하고, | ||
| + | \\ | ||
| + | \\ | ||
| + | |||
| + | <code java> | ||
| + | package com.ocean.cryto.md5; | ||
| + | |||
| + | import org.apache.commons.codec.digest.DigestUtils; | ||
| + | |||
| + | public class MD5HashDemo { | ||
| + | |||
| + | public static void main(String[] args) { | ||
| + | // Calculates the MD5 digest for the password text and returns | ||
| + | // the value as a 32 character hex string | ||
| + | String password = " | ||
| + | String digest = DigestUtils.md5Hex(password); | ||
| + | |||
| + | // Prints the plain text password, the digest and the Length of the digest | ||
| + | System.out.println(" | ||
| + | System.out.println(" | ||
| + | System.out.println(" | ||
| + | |||
| + | // Calculates the MD5 digest for the Long texts. | ||
| + | String md5 = """ | ||
| + | The MD5 message-digest algorithm is a formerly \ | ||
| + | widely used cryptographic hash function that produces \ | ||
| + | a 128-bit (16-byte) hash value. Specified in RFC 1321, \ | ||
| + | MD5 has been utilized in a wide variety of security \ | ||
| + | applications, | ||
| + | integrity. MD5 was designed by Ron Rivest in 1991 to \ | ||
| + | replace an earlier hash function, MD4. An MD5 hash value \ | ||
| + | is typically expressed as a hexadecimal number, 32 \ | ||
| + | digits long. | ||
| + | """; | ||
| + | String fingerprint = DigestUtils.md2Hex(md5); | ||
| + | |||
| + | // Prints the text, the fingerprint and the Length of the digest / fingerprint | ||
| + | System.out.println(" | ||
| + | // Text = The MD5 message-digest algorithm is a formerly widely used cryptographic hash function that produces a 128-bit (16-byte) hash value. | ||
| + | // Specified in RFC 1321, MD5 has been utilized in a wide variety of security applications, | ||
| + | // MD5 was designed by Ron Rivest in 1991 to replace an earlier hash function, MD4. An MD5 hash value is typically expressed as a hexadecimal number, 32 digits long. | ||
| + | System.out.println(" | ||
| + | System.out.println(" | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | \\ | ||
| + | \\ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== 용어 ==== | ||
| + | ^ 용어 | ||
| + | | SHA | Secure Hash Algorithm, 안전한 해시 알고리즘 | ||
| + | | SHA-256 | ||
| + | | SHA-384 | ||
| + | | SHA-512 | ||
| + | |||
| 줄 36: | 줄 132: | ||
| \\ | \\ | ||
| [[https:// | [[https:// | ||
| + | \\ | ||
| + | [[https:// | ||
| \\ | \\ | ||
| [[https:// | [[https:// | ||
| 줄 62: | 줄 160: | ||
| \\ | \\ | ||
| [[https:// | [[https:// | ||
| + | \\ | ||
| + | [[https:// | ||
| \\ | \\ | ||