Encrypt the user data without loosing logged in user in android app

Viewed 133

I have an app launched on play store. The app has the signup and sign in process. After sign in application is encrypting the user credentials with this library and storing them in shared preferences and also the credentials are decrypted with same library before using the credentials for direct login to the app without entering username and password again and again. But I think this library would not fit my application for encryption and decryption so I found a way for this. I wrote my code in C++ for encryption and decryption and the code is working well. Now I want to add this logic to my existing app and update my app on play store without loosing the previous logged in user. How can I achieve this logic. Any small hint will be appreciated. One of the logic I found was to logout the user if this this version of application is downloaded, but this logic is not satisfied by the client.

1 Answers

Here is the solutions for you.

  1. Add some prefix to the encrypted data during encryption in your encryption method, So that you could figure out if the data is already encrypted or not.
  2. During decryption, if the prefix is present in the data that means it is encrypted and you need to decrypt it otherwise you could just proceed further.

Note: Make you prefix some unique like your package name so that it will have less chance of occurrence in the data saved in pref.

Related