UPI Study › Courses › Database Programming › Free lessons › Lesson 12.6 Free with a free account
Encrypting Database Data: Methods and Applications
Database Programming · Chapter 12: Database Security and AuditingSection 12.6 · lesson 75 of 7611 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Database Programming.
Lesson complete
Earn the 3 college credits for Database Programming
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Auditing Databases: Tracking Activity and Ensuring Compliance →← Advanced Techniques for Protecting Database SystemsNext lesson: Auditing Databases: Tracking Activity and Ensuring Compliance →
A free account plays all of Chapter 1 and 3 more lessons of Database Programming. Create a free account →
In this lesson
Choose encryption at rest, in transit or per column, and manage keys.
- Distinguish encryption at rest, in transit and at the column level
- Explain what Transparent Data Encryption and TLS protect and leave exposed
- Compare MySQL column encryption functions with SQL Server Always Encrypted
- Explain why passwords need salted hashing and keys need lifecycle management
Free study notes
Get this lesson's notes by email
The key points and 4 practice questions with answers, in your inbox. One email, free.
One email. Unsubscribe in one click.
Transcript
Everything said in the video, section by section (1,320 words). Read along, or search it.
Opening Scenario
Who Should Be Able to Decrypt
Maya Rao owns fictional Lantern Books. She asks Amina Diallo, the database administrator, to protect a backup before it leaves the building. Amina asks a second question: who should be able to decrypt it? Hiding a file from a thief differs from hiding a field from an administrator. Their choices will depend on where information is exposed, and where the keys live. Can one encryption setting solve both problems?
Key Terms
Plaintext, Ciphertext, Rest and Transit
Plaintext is readable data. Ciphertext is its encrypted form, produced using a cryptographic algorithm and key material. Encryption is reversible for an authorized holder of the right key. The algorithm can be public; the secret key must remain protected. Data at rest lives in files, storage, and backup copies. Data in transit travels between systems, including the application and database. Column-level encryption protects selected values. It can put the decryption boundary somewhere different from the boundary around the entire database file. Amina starts with the threat, rather than the product name. Ask what the attacker can copy, observe, query, or administer.
Encryption at Rest
Transparent Data Encryption for Database Files
Transparent Data Encryption, or T D E, protects database files at rest. The engine encrypts stored pages and decrypts them as it reads. Ordinary application queries can remain unchanged. A person allowed to select customer data can still receive readable results. For SQL Server, database encryption uses a data encryption key, protected by a certificate or another supported protector. Protect and back up that recovery material. Availability of features depends on version and edition. For example, SQL Server Standard gained T D E in twenty nineteen; check the selected deployment. MySQL InnoDB uses a keyring-backed hierarchy and tablespace encryption options. Enabling an option without the required keyring setup is not a complete deployment.
Backups and Dumps
Check the Actual Copy Format
Amina checks the backup format separately. SQL Server T D E protects its database backups, but a plaintext export is a different artifact. For MySQL, an encrypted tablespace does not make a logical dump encrypted. The dump contains readable sequel and values unless separately protected. The illustrated MySQL table option requests encryption, after the keyring and storage prerequisites are ready. This is a non-run server example. Do not judge protection by a filename or checkbox. Inspect the actual copy path and rehearse restoration with the required keys.
Encryption in Transit
TLS and Server Certificate Checks
Transport Layer Security, or T L S, protects the connection. It helps prevent network observers from reading or modifying traffic between the application and server. Require encryption, and verify the server certificate and expected server identity. Encrypting a connection to an impostor does not establish the intended destination. MySQL can require encrypted connections for an account. SQL Server provides server encryption settings, while clients also configure their connection requirements. Inspect the active connection, rather than assuming a setting took effect. MySQL exposes a session cipher; SQL Server reports an encrypt-option text value such as true. Connection encryption ends at its endpoints. It does not encrypt a stolen disk, or stop an authorized application from revealing a returned value.
Column Encryption
MySQL AES Functions and Their Limits
Column encryption can protect selected sensitive values. MySQL offers A E S encrypt and A E S decrypt, with ciphertext stored in a binary column. The server receives the plaintext and key material for those function calls. Keys or values can leak through query logging or inappropriate diagnostic access. That design does not reliably hide the secret from a fully privileged database administrator. T L S protects transport, but does not move encryption outside the server. The default E C B mode reveals repeated blocks. A stronger construction needs proper randomness, an initialization vector where required, and integrity protection. Choosing C B C alone is not a complete security recipe. Use reviewed cryptographic libraries and key-management guidance, rather than assembling an ad hoc scheme.
Client-Side Encryption
SQL Server Always Encrypted
SQL Server Always Encrypted moves ordinary encryption and decryption into a supported client driver. Key access is separated from routine database administration. The driver encrypts parameters before sending them, and decrypts results for authorized applications. Server storage contains ciphertext for the protected columns. Set up column master and encryption keys, encrypted column metadata, and the driver's column-encryption connection setting. Application and driver support still matter. A server administrator without client key access cannot simply decrypt those ordinary protected values. A compromised authorized client remains a different threat. Amina verifies where plaintext exists in memory, in logs, and after results leave the database. Client encryption does not protect every later use automatically.
Searching Encrypted Data
Deterministic Versus Randomized Encryption
Deterministic encryption produces equal ciphertext for equal plaintext under the same settings. That can support equality operations, while revealing repetition patterns. Randomized encryption obscures that equality pattern. Ordinary server comparisons become more restricted, so existing filters, joins, and indexes need review. Always Encrypted with secure enclaves changes some limitations. A protected execution environment can support additional operations, with its own trust and configuration requirements. Avoid a blanket promise that encrypted data is searchable, or never searchable. The feature, encryption mode, and threat model determine what is possible.
Quick Check
A Certificate That Fails Validation
A client receives an unexpected certificate when reconnecting to its database. The endpoint name appears familiar, but its certificate does not validate. Which response preserves the intended trust boundary? Pause, and decide. Reject the connection pending investigation. Verify the certificate and configuration through a trusted channel before sending sensitive data. Accepting the new identity automatically, or disabling peer checks, could connect securely to the wrong server. Encryption alone does not settle identity.
Password Hashing
Salted, Slow Hashes for Passwords
Hashing solves a different problem. A cryptographic hash produces a fixed-length digest, with no decryption key that recovers the input. That does not prevent guessing. An attacker can try likely inputs and compare their hashes, especially when the original value is a weak password. Passwords need a purpose-built password library, with a unique random salt and an appropriate work factor. Argon two i d is a common modern choice. Scrypt and bcrypt are other established password-library options, with deployment-specific limits. A salt is stored with the hash; it need not be secret. Raw S H A two is too fast for password storage. Encryption suits data the application must recover; password hashing suits checking a secret without recovering it.
Key Management
Storing, Rotating and Retiring Keys
Key management covers creation, storage, access, backup, rotation, and retirement. A strong cipher cannot compensate for a key stored beside the exposed data. A vault or hardware security module can protect high-value keys. Separate key access from ordinary database duties, and record key use and changes. Envelope encryption uses a wrapping key to protect a data key. Replacing the wrapper can avoid encrypting the whole dataset again. Replacing the data key is a different operation. Old backups may still require old protectors, so rotation must include recovery planning. For SQL Server T D E, create and back up the certificate in master. Reference its protector from shop, and preserve its private key securely. For MySQL, InnoDB master-key rotation replaces the wrapping protection. Test restoration, and retire a key only when no retained data still needs it.
Second Check
Recovering a Snapshot After Key Rotation
A rotated key is no longer used for new backups, but the team must still recover an older retained snapshot. What should happen to the old key's recovery material? Pause, and decide. Maintain a separately controlled escrow: a protected recovery arrangement. A retained backup still depends on its earlier protector. Discarding it could make required recovery impossible. Keeping plaintext keys beside the snapshot would expose both to the same theft.
Resolution
An Encrypted Backup With Separate Keys
Back to Maya's backup, Amina chooses encryption for the actual backup artifact and stores recovery material under separate controlled access. She also verifies encrypted connections and reviews whether sensitive fields need a client-side key boundary. Those are separate decisions about separate exposures. Maya now asks for a restoration rehearsal as well as an encryption setting. Protection is useful only when authorized recovery remains possible.
Key Takeaways
Match Encryption to the Exposure
Match file, connection, and column encryption to the exposure you need to address. Locate the plaintext and keys, including clients, logs, and recovery copies. Use password hashing for password verification, with salt and a suitable password library. Protect the entire key lifecycle, and test recovery before retiring old protectors.
About Database Programming at UPI Study
Database Programming (Computer Science 381) is a self-paced online course of 76 video lessons in 12 chapters, from database applications, SQL setup, schema planning and normalization to keys and constraints, data types, filtering and sorting, joins, subqueries, views, indexes, ROLLUP and PIVOT, regular expressions and database security. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Computer Science courses Every credit course with PRO →
Why take it here
Why students take Database Programming with UPI Study
Where the credit goes
Universities that work with NCCRS
Database Programming carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Encrypting Database Data: Methods and Applications
What is Transparent Data Encryption (TDE)?
What is the difference between encryption at rest and encryption in transit?
Should passwords be encrypted or hashed in a database?
What is SQL Server Always Encrypted?
About the Database Programming course
How many college credits is Database Programming?
How much does Database Programming cost and what is included?
Which universities accept UPI Study credits?
How long does Database Programming take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Database Programming.
76 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
Updated
3 credits · NCCRSEnroll →