WoJo
WoJo

Reputation: 516

Non-user-readable file for sensitive info

I'm trying to send a mail via my app, and I got it working but there's one problem. I have to hard code the password. This is my code:

            var client = new SmtpClient("smtp.gmail.com", 587)
            {
                Credentials = new NetworkCredential("[email protected]", PASSWORD),
                EnableSsl = true
            };
            client.Send("[email protected]", "[email protected]", "test", "testbody");
            Console.WriteLine("Sent");
            Console.ReadLine();

I don't want users to be able to see the password when they decompile the apk. Is there any way to store a variable (Or something like that) to save sensitive information that users will not be able to encrypt/read on any possible way?

Upvotes: 0

Views: 47

Answers (1)

Milney
Milney

Reputation: 6417

Nope. Sadly not. Only slow people down.

You probably want to host an API, and send a request to that - which then sends the emails. Then your password is on not in the app. People can still mimic the requests to your API - but then atleast only the emails you want are sent, and you can use some logic like limiting the amount sent by a given user etc.

You can try one of these techniques if you dont think people will try too hard to break it - https://github.com/codepath/android_guides/wiki/Storing-Secret-Keys-in-Android, but a determined attacker will always be able to get them

Upvotes: 1

Related Questions