How to use AES encryption and decryption in Android

Today, I have encountered many problems when using AES to encrypt and decrypt data in the Android project. I have also found a lot of information on the Internet. But in the end, I got it. Record this here. Don't let others take my detour, because most examples on the Internet don't work. OK, let's start

1. AES tool class

2. The mainactivity and layout files are as follows:

Layout file

3. The final effect is as follows:

1) . is an input box for inputting the string encrypted by the key;

2) . the encrypted string produced after clicking the "AES encryption" button;

3) Click the "AES decryption" button to decrypt the encrypted string, and then see the decrypted string in 3 places. You can see that the encrypted string is the same as the decrypted string, so AES encryption and decryption succeeded

4. Summary

If you want to test with a real machine, the simulator will not work. The specific reasons have not been studied; Click to get the GitHub address of this example: you can also directly git it through Android studio. The GIT address is https://github.com/chenguo4930/AndroidAES.git Among them, the GitHub address of the encryption and decryption demo of DES and RSA is https://github.com/chenguo4930/EncodeDemo Git address is: https://github.com/chenguo4930/EncodeDemo.git

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

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
分享
二维码
< <上一篇
下一篇>>