1, encoding format, the Unicode encoding standard, the digest algorithm, the binary conversion method Base64, url encode, symmetric encryption, asymmetric encryption (public key cryptography), a digital signature algorithm, the MAC algorithm

Copyright Notice: Welcome to reprint exchange, to declare the source. Performance status prior to the state of mind, habits prior to determination, focus first on preferences --Bestcxx https://blog.csdn.net/bestcxx/article/details/90707630

Foreword

Performance status prior to the state of mind, habits prior to determination, focus first on preferences

Several confusing concept

Encoding format such GBK, UTF. 8-
the Unicode is a standard specification, in fact, the conventional 8-bit, 16-bit and 32-bit encoding unit, respectively, UTF-8, UTF-16, UTF-32
digest algorithm such as the MD5, is irreversible , the common language detection data integrity
binary conversion method is based on Base64 64 printable characters to represent binary data method, and can speak binary strings consisting of conversion, this is not emphasized encryption
url encode, for the url Chinese special characters and escape, normal browser to facilitate processing
of symmetric encryption algorithms, such as DES, AES, is a characteristic section of data encryption, the same key to encrypt and decrypt
asymmetric encryption algorithm such as the RSA, two key characteristics are needed, commonly called Private key and public key, encrypted using one key, the other key can decrypt.

Encoding format

Unicode encoding standard

ASCII、UTF8、GBK、gb2312 等

Digest Algorithm

Base64 Profile

Base64 is based on 64 printable characters to binary data representation.
See RFC2045 ~ RFC2049 can
actually To some extent, Base64 and more like the UTF8, GBK same encoding format, except that, Base64 only to the byte array into a string - looks untidy , so you they can not be recognized as a character encoding format, such as UTF8 or GBK, you know they can be a literal or symbolic.

Base64 is provided between the transforming ability byte data string and

Base64 provides the ability to:
1, the byte array into Base64 encoded string - look like garbled
2, the Base64 string into a byte array
as to set the number of characters, which may come from the character encoding format UTF8 string, the string may also come from GBK encoding, but in any case, when using Base64 encoded string encoding format you do not need to be concerned about the problem

The standard Base64 encoding rules

Essentially, Base64 into a byte characters and implementation rules.
The Base64 uses 64 symbols substantially printable

Figures 10: 0-9
26 lowercase letters: AZ
26 is uppercase letters: AZ
2 symbols: + /

Base64 encoding rules exist variant

Since the standard Base64 existing symbols + and / are automatically escaped in some scenes, so use Base64 actual applications, such as in the URL in the database in question will involve the conversion of special symbols.
You can understand is, in actual use, Base64 encoded character is not limited to substantially 64 symbols, may contain other symbols according to a particular variant, such as =, -!, _ etc.

The following excerpt Baidu Encyclopedia:
standard Base64 into the URL is not suitable for direct transmission, since a URL standard Base64 encoder will the "/" and "+" character becomes the form "% XX", and these "%" No need to convert into a database Shihai, because ANSI SQL has been in "%" was used as a wildcard.
To solve this problem, URL's can be used for improving Base64 encoding, in which the end of filling '=' sign, and the standard Base64 "+" and "/" are changed to "-" and " .", this eliminates the need at the time of conversion and URL database stores codec to be made, to avoid increasing the length of the coding information in this process, and unified database format, etc. form the object identifier.
There is the regular expression for improvement Base64 variant, it will "+" and "/" changed and "!", "-" because "+", "*" and used earlier in the IRCu " [ "and"] "in the regular expression may have special meaning.
There are also some variants, they will "+ /" to "
-" or. " (Used as an identifier name programming languages) or" .- "(Nmtoken XML is used) and even" " :" ( Name XML used in).

Base64 encoded than the original length of about 1/3 of the character

8Bit Base64 requires the three bytes of each byte is converted to four 6Bit (3 . 8 = 4 6 = 24), then add another two high 6Bit 0, 8Bit four bytes of the composition, i.e., string theory converted to 1/3 than the original length.
The reason is theoretical, because the rules are different character encoding format for processing is not the same, there are varying degrees of problems fill the seats.

Base 64 is not encryption algorithm

Base64 most common misconception is the task which is an encryption method, which is a big mistake.
Its use is generally encode- view encoding and decoding decode-
The main problem to solve common expression between different character encodings

Base64 usage scenarios

Since distortion appears Base64 general, it can be used as part of the data processing
Base64 can be used for data exchange between different systems - it is not a character coding attributes, not the so-called garbage problem - of course, you will restore Base64 when the original character encoding format string corresponding to still pay attention.

Base64 use in Java

Methods Apache Commons Codec provide advice to use jdk1.8 provided, or.
Venue: Base64 several implementations in Java

url encode

Symmetric encryption

Asymmetric encryption (public key encryption)

RFC2246: The US government may not contain more than 512 bit RSA encryption export key module of the software, but does not limit greater than 512 RSA algorithm key for a digital signature.
RSA asymmetric encryption, the encrypted plaintext constraint length 117, is decrypted ciphertexts limit 128

Digital Signature Algorithm

MAC algorithm

Reference material

[1] https://www.cnblogs.com/sunxuchu/p/5483956.html
[2] https://www.jianshu.com/p/a8070920810d
[3] https: //www.cnblogs. com / sunxuchu / p / 5483956.html
[4] https://baike.baidu.com/item/base64/8545775?fr=aladdin
[5] https://blog.csdn.net/qq_20545367/article/ details / 79538530

Guess you like

Origin blog.csdn.net/bestcxx/article/details/90707630