Detailed explanation of data encryption methods commonly used by Android

preface

Android needs to use data encryption on many occasions, such as local login password encryption, network transmission data encryption, etc. The general encryption methods in Android are as follows:

Or AES encryption RSA asymmetric encryption MD5 encryption algorithm

Of course, there are other ways. Let's introduce the use of the above four encryption algorithms for the time being.

Or encryption algorithm

What is or encryption?

Or encryption is to perform or operation on a byte, such as byte a ^ k = V, which is the encryption process; When you put V ^ k, the result is a, that is, V ^ k = a, which is a reverse operation process, decryption process.

Or the operation efficiency is very high, of course, or encryption is also a relatively simple encryption method, and the operation will not increase the space, the size of the source data, or the size of the encrypted data.

The example code is as follows:

You can encrypt part of the file, such as the zip compressed package, you can encrypt the head and tail, because the zip head and tail contain information related to file compression. Therefore, we can encrypt the whole zip file only by using or encryption algorithm for the head and tail. When you don't decrypt and try to pressurize, you will fail. You can also encrypt the whole file, so when you decrypt, it is actually a reverse process. You can decrypt the encrypted file with the same method and the same key. Of course, the security of encryption can be imagined in the future. It is not very secure. Therefore, or encryption algorithms are generally used in less important scenarios. Because the algorithm is very fast, the encryption speed is also very fast.

AES encryption algorithm

What is AES encryption

AES symmetric encryption

Advanced Encryption Standard (AES), also known as Rijndael encryption method in cryptography, is a block encryption standard adopted by the federal government of the United States. This standard is used to replace the original DES, which has been analyzed by many parties and widely used all over the world.

The AES encryption key in Android must be 16 / 24 / 32-bit bytes, otherwise an exception will be thrown

Example code:

AES symmetric encryption, encryption and decryption is a little more complex than or encryption, and the security is also higher than or encryption. AES encryption is not absolutely secure.

RSA asymmetric encryption

What is RSA encryption?

RSA algorithm is the most popular public key cryptography algorithm, which uses keys with variable length. RSA is the first algorithm that can be used for both data encryption and digital signature.

The security of RSA depends on large number decomposition. N less than 1024 bits has been proved to be unsafe. Moreover, because RSA algorithm performs large number calculation, the fastest situation of RSA is twice slower than DES, which is the biggest defect of RSA. Therefore, it can only be used to encrypt a small amount of data or encryption keys, but RSA is still a high-strength algorithm.

Code example:

MD5 encryption algorithm:

1. AES public key encryption and private key decryption 2. AES encryption takes time 3. The data will become larger after AES encryption

summary

The above is all about the detailed explanation of the data encryption methods commonly used by Android in this paper. I hope it will be helpful to you. If there are deficiencies, please leave a message to point out. Thank you for your support.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>