Original address: https://blog.csdn.net/u013718120/article/details/56486408
Data security can be said to be the top priority. The frequent security incidents in the past two years have also been fired up. How to enhance data security, let's chat.
Safety, the large range makes people breathless. About safety knowledge and how to prevent it, I will not be involved for the time being. If you step on it deeply, your scalp will easily become numb. Let's start with the simplest encryption.
The encryption algorithm has been encapsulated into a library library, and the process has been explained in detail. At the same time, segment encryption and padding encryption of RSA, multiple encryption and salt encryption of MD5 are implemented . It has been shared to github. You can follow, fork, and quickly reference it in your own project. Don't forget to give a star when you are happy ~
This article still revolves around encryption on the Android platform. About 8 commonly used encryption methods are summarized, and the process is clearly displayed, which is convenient and quick to get on the bus! driving~
1.DES ,3DES
Overview: Symmetric Encryption Algorithms
Advantages: open algorithm, small amount of calculation, fast encryption speed, high encryption efficiency
Disadvantages: Both parties use the same key, security is not guaranteed
2.AES
Overview: Symmetric Encryption Algorithms
Advantages: open algorithm, small amount of calculation, fast encryption speed, high encryption efficiency
Disadvantages: Both parties use the same key, security is not guaranteed3.XOR
Overview: XOR encryption: the original character or number m is XORed with a value k to get the result r, then the XOR operation with r and k can be restored to m
Advantages: exchange of two variables (without the aid of a third variable), simple data encryption
Disadvantage: simple encryption method4.Base64
Overview: It's not an encryption algorithm, it just encodes and transmits data
5. SHA
Overview: Asymmetric encryption algorithms. Secure Hash Algorithm, Digital Signature Tool. The famous image loading framework Glide uses this encryption when caching keys
Advantages: high difficulty in cracking, irreversible
6. RSA
Overview: Asymmetric encryption algorithm, the most popular public key cryptography algorithm, uses a variable-length secret key
Advantages: irreversible, can be used for both data encryption and digital signatures
Disadvantages: RSA asymmetric encryption has a limited content length, and a 1024-bit key can only encrypt up to 127-bit data7. MD5
Overview: Asymmetric encryption algorithms. The whole process: Message-Digest Algorithm, translated into message digest algorithm
Advantages: irreversible, compressible, not easy to modify, easy to calculate
Disadvantage: Exhaustive method can be crackedFrom the above brief introduction, we found that the algorithms are divided into two categories:
(1) Symmetric encryption algorithm
(2) Asymmetric encryption algorithm
Their characteristics are also clear at a glance:
(1) Symmetric encryption algorithms can be reversible, that is, encrypted by key or decrypted by key
(2) Asymmetric encryption is irreversible
I believe that this concise summary allows you to easily understand the advantages and disadvantages of each encryption algorithm and usage scenarios. Don't be afraid to meet the interviewer