Base64 SHA1 MD5

Base64 encoding

1: Base64 is one of the most common encoding methods for transmitting 8Bit bytecode on the Internet. Base64 is a method of representing binary data based on 64 printable characters.
2: Base64 encoding is a process from binary to character. It can be used to transmit long identification information in the HTTP environment
3: The encoded data is a string, which contains characters: AZ, az, 0-9, +, /
A total of 64 characters: 26 + 26 + 10 + 1 + 1 = 64. In fact, it is 65 characters, "=" is the padding character
4: 64 characters need 6 bits to represent, and the value is 0~63

write picture description here


Base64 encoding process

1: The string "Xue" becomes "WHVl" after Base64 encoding. The number of data bits with a length of 3 bytes is 8*3=24, which can be accurately divided into 6*4
write picture description here

2: If the number of bytes of data is not a multiple of 3, then its number of bits is not a multiple of 6, so it cannot be accurately divided into 6-bit blocks. In this case, one or two zero-valued bytes need to be added after the original data, so that the number of bytes is a multiple of 3. Then, add one or two equal signs "=" after the encoded string to indicate the number of zero-valued bytes added. Example:
The string "Xu" becomes "WHU=" after Base64 encoding.

write picture description here


md5/SHA1 hash algorithm

1: MD5 algorithm:
1> Compressibility: For data of any length, the length of the calculated MD5 value is fixed.
2>Easy calculation: It is easy to calculate the MD5 value from the original data.
3> Modification resistance: any modification to the original data, even if only 1 byte is modified, the MD5 value obtained is very different.
4> Strong anti-collision: Knowing the original data and its MD5 value, it is very difficult to find a data with the same MD5 value (ie forged data)
2: SHA1 algorithm
and MD5 similar processing;
3: Encrypt user password, server Store user passwords are all MD5 values;
4: Compare whether the file has been modified, and generate MD5 values ​​according to the content of the file;


base64 encoding

write picture description here


base64 decoding

write picture description here


MD5

write picture description here

Online verification tool

write picture description here

SHA1

write picture description here


code

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325227557&siteId=291194637