Programming Measures to Take When Dealing With Sensitive Data

Ngenge Senior
Jun 17, 2019 · 4 min read
Photo by Scott Webb on Unsplash

In the internet age, access to data is power and thus as a programmer or software engineer or technocrat, the ways you handle data is very crucial. A single mistake of mishandling data could bring down a big organization. The
sensitive data we are talking about here include data like passwords, user names, pins, API keys, financial data, and many others.

In this post, we look at some measures that a developer should take when dealing with such data.

Enforce Authentication

Authentication is the process of determining whether a person or thing is who or what they claim to be. When dealing with sensitive data, always ensure that authentication is a requirement. For example, take the case of a banking application, it would be always necessary that a user is identified by a maybe a user name and a pin. Other ways of enforcing stronger security are using methods like Two-factor authentication(2FA) and Multi-factor authentication(MFA).

Never Hard code credentials in Code

This is one of the most common mistakes that one can find around. The mistake of hard coding credentials like database passwords, API keys, private keys and pins in code. Doing such saves a hacker the stress of doing brute-forcing or other methods as you are the one who has handed him credentials for free.APIs usually have what is referred to as rate limiting. If another person uses your API key, you might run out of the number of API calls that you can make. The worst comes to the worst when you are paying for such APIs and another party is using. There are ways of storing these credentials when developing for platforms like mobile and the web. Links will be provided later.

Never save credentials without encryption

The mistake that even big giants like Facebook made was saving user passwords as plain text. It was reported that the social media giant stored millions of Facebook and Instagram passwords without encrypting the passwords. It is definitely one of the silliest things to do when writing software involving sensitive data. Even if a hacker(s) finally gets access to your data, make sure that the data is useless to the hacker(s). This can only be made possible by enforcing strong encryption techniques to credentials before the credentials are saved.

Never commit a transaction when it not complete

To make this point clearer, let me take a classic example of making transaction in a banking application as follows;

Some people might think that there is nothing wrong with this pattern as it seeming solves what it is supposed to do. What the method fails to consider is a situation when there is a failure, such as a network error occurs and the transaction does not go through and you must have deducted the funds from A. So you will be left with person A’s account deducted by $4000 but person B’s account was not credited. This can cause great financial loss and issues leading to customers losing confidence in their service providers, in this case, banks.

One way of handling this is that there can be a sort of pool for transactions such that when A intends sending funds to B, the following logic is taken;

This might look like a long pattern but just a few lines of properly written code should do this.
This might look like a focus on one domain, but the point is that you should save any type of transaction, only when all previous stages are marked as successful.

Enforce the CAPTCHA Stuff

A CAPTCHA (Completely Automated Public Turing Test To Tell Computers and Humans Apart) is a program that protects websites by telling whether or not a user is human or a bot. The most common form of CAPTCHA is one that requires the user to type distorted text in a text field to identify as human. Many users hate CAPTCHAs but the check is very necessary. One way of attempting a login system is through a dictionary attack. With CAPTCHA, you can prevent this by letting a user solve CAPTCHA after a number of unsuccessful authentication thus preventing them from going through the entire list of passwords.

CAPTCHAs also prevent situations like email scrapping, spamming and lots more. Find more about CAPTCHAs at this link, .

There is a lot of checks that should be done when dealing with sensitive data. These are the few that one can consider for a start in order to prevent various misfortunes that come by poorly securing data. I leave you two useful links of how to store secret keys for Android developers and iOS developers.

Useful links

The Startup

Medium's largest active publication, followed by +588K people. Follow to join our community.

Ngenge Senior

Written by

Android and Kotlin developer. Co-founder @ Njaka. Android developer mentor @ Udacity.A little blockchain

The Startup

Medium's largest active publication, followed by +588K people. Follow to join our community.

More From Medium

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade