The principle and summary of ATITIT.MD5 algorithm

Source: Internet
Author: User
Tags base64

the principle and summary of ATITIT.MD5 algorithm

1 .  MD5 Number of bits 1

2 .  converts a byte array to a four-bit string base16 1

2 . 1. hexadecimal characters are represented by 4 bits. 1

2 . 2. byte[] and hexadecimal strings are converted to each other 2

3 .  base64 notation of MD5 3

4 .  Reference 3

1.MD5 number of digits 128 bits

Generates a byte array that is in bytes:

2.the byte array is converted to a 32-bit string Base16

Every 4 guests can 1111

Just 0--f can fully identify the 4 bit bits.

2.1.hexadecimal characters are represented by 4 bits.

Each character in hexadecimal needs to be represented by a 4-bit bits

2 of four times equals 16. So to use 4 bits to represent a hexadecimal character

Author:: Old Wow's paw attilax Ayron, email:[email protected]

Reprint please indicate source: Http://blog.csdn.net/attilax

As shown below:

0

0000

1

0001

2

0010

3

0011

4

0100

5

0101

6

0110

7

0111

8

1000

9

1001

A

1010

B

1011

C

1100

D

1101

E

1110

F

1111

2.2.byte[] and hexadecimal strings are converted to each other

In Java, Byte uses a binary representation of 8 bits, and we know that each character in the 16 binary needs to be represented by a 4-bit bits.

So we can convert each byte to two corresponding 16 characters, that is, the high 4 and low 4 bits of byte are converted to the corresponding 16-character H and L, and combined to get the result of byte conversion to the 16 binary string.

New String (H) + new String (L).

In the same way, the opposite conversion also converts two 16 characters into a byte, as in the same principle.

Based on the above, we can convert the byte[] array to a 16-binary string, and of course we can convert the 16-string to the byte[] array.

3.base64 notation of MD54.Reference

Java byte array and hexadecimal string transfer - Xin Xin Brother's personal page - Open source China Community . htm

Java takes Advantage of messagedigest to get a string or file MD5 detailed - mouse hole - Open source China Community . htm

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The principle and summary of ATITIT.MD5 algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.