DEV Community

John Mercier
John Mercier

Posted on

Plain text vs plaintext

Sometimes when we are programming we don't always do the right thing. This can easily be the result of how a requirement is phrased and a lack of context in assigned tasks. Lets take this example.

No password may be stored as plaintext.

If this were presented to a developer implementing a way to store passwords what would happen? Some developers may see this and think they only need to encode the password using Base64. Other developers may see this and think passwords should be encrypted. These are two very different solutions.

The problem is in the way the requirement is presented. If this is presented as a one line task assigned to a developer you may end up with the Base64 encoding solution. The task lacks context. It doesn't provide a reasoned argument for the requirement which may indicate which solution is better. That context may look something like this.

Passwords are a security mechanism meant to prevent access to some part of a system. Passwords should not be stored as plaintext so they cannot be easily exploited to gain access to the system.

No password may be stored as plaintext.

With this context a developer may understand that Base64 encoding is easy to recognize and decode to gain access to the system.

There is also an ambiguity in the requirement that is not being addressed. The ambiguity is in the meaning of plaintext. Plain text has two definitions.

Developers wanting to use Base64 encoding are defining plain text as readable text.

Plain Text

In computing, plain text is a loose term for data (e.g. file contents) that represent only characters of readable material but not its graphical representation nor other objects (floating-point numbers, images, etc.).

Developers wanting to use encryption are defining plain text as unencrypted data.

Plaintext

In cryptography, plaintext usually means unencrypted information pending input into cryptographic algorithms, usually encryption algorithms. Cleartext usually refers to data that is transmitted or stored unencrypted ("in clear").

The requirement should clear the ambiguity by addressing what is meant by plain text.

Passwords are a security mechanism meant to prevent access to some part of a system. Passwords should not be stored as plaintext so they cannot be easily exploited to gain access to the system.

No password may be stored as plaintext. Meaning, passwords should not be store as unencrypted data or "in the clear."

When writing tasks for other developers it is important to:

  1. provide clarity by giving the context of a problem
  2. remove any ambiguity that may result in an unintended solution

Top comments (0)