I’m curious if there is a way to decompile and access flutter codes from a release apk? and how to prevent that? if there is no way to prevent, so how to keep data securely?
In my case i have to keep user name and a password static , how can i secure them and prevent them to be accessed?
It’s just an android version not ios.
2
Answers
There is no way of safely storing a secret in your dart code, it will always be possible to reverse engineer the apk and find the secret. See this question for better explanation.
The main question is then: Why do you need to hard code a username and a password? Maybe another way is possible that does not require to have access to this information in the app. Having a backend which does all the requests to the authenticated service you want to access can be a solution.
To answer your case maybe you can check the code below. The code source
From that code, you generate a random
secure key
that will be used to encrypt and decrypt a data with AES Encryption. From the code, there are two storage libraries, flutter_secure_storage and hive. Since the flutter_secure_storage is good for security, the random security key will be saved using this library. And the Hive is good for fast and light databases. A combination of both libraries will be good to achieve your case.Also, check this article. The article is a good guide to help increase the security of the Flutter app.
https://medium.com/kbtg-life/mobile-security-via-flutter-ep-1-ssl-pinning-c57f18b711f6
https://medium.com/kbtg-life/70b4322bffc2
I followed several guidelines from the article so that my application passed the penetration test.