liveBook · Manning

One-way encryption

As explained in Grokking Relational Database Design

One-way encryption transforms input data into a fixed-size representation designed to be computationally impractical to reverse.

One-way encryption transforms input data into a fixed-size, seemingly random string. Also called hashing, it is designed to be practically impossible to reverse, especially for longer values. section 7.4

It is especially useful for passwords. A database stores the hash rather than the plain-text password, limiting the damage if an unauthorized person obtains the database. section 7.4

A practical password-storage change involves these steps:

  • Choose a one-way algorithm such as bcrypt, PBKDF2, or Sha512. section 7.4
  • Hash passwords before storing them instead of keeping their original values. section 7.4
  • Size the password column for the encoded result; the bcrypt example changes it to CHAR(60). section 7.4

Revising a password column

For the user table, replace a plain-text password column with storage for the bcrypt result: ALTER TABLE user MODIFY COLUMN password CHAR(60); Binary results may be encoded as ASCII, such as with Base64, for easier storage and handling. section 7.4

How Grokking Relational Database Design covers it

How deep it goes
Defines hashing, gives security rationale, names algorithms, and applies the idea to a column-size change.
Examples
Uses bcrypt password hashes, a user table, CHAR(60), and Base64 encoding as concrete examples.
What you can do after
Apply it via a named algorithm and revise a password column for the resulting stored representation.
How it connects
Connects hashing with passwords, symmetric encryption, binary encoding, and database schema design.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Relational Database Design. The section links point to the parts of the book it draws on.