Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Elixir
  3. phoenix-ecto-encryption-example

phoenix-ecto-encryption-example

Elixir

A step-by-step example of encrypting sensitive data in Elixir Phoenix apps using Ecto custom types before storing in a database.

GitHubGitHub
291 stars21 forks0 contributors

What is phoenix-ecto-encryption-example?

Phoenix Ecto Encryption Example is a detailed tutorial and code example that demonstrates how to implement field-level encryption in Elixir Phoenix applications. It shows how to encrypt sensitive user data before storing it in a database using custom Ecto types, addressing the critical need for personal data protection in web applications. The project solves the problem of securing personal information like names and email addresses while maintaining application functionality.

Target Audience

Elixir/Phoenix developers and technical decision makers who need to implement robust data encryption in their applications. It's particularly valuable for developers building applications that handle personal data and require compliance with data protection regulations.

Value Proposition

Developers choose this example because it provides a complete, production-ready implementation of encryption following OWASP best practices, with clear explanations of each step. Unlike generic encryption libraries, it demonstrates the full integration with Phoenix and Ecto, including key rotation and custom type implementation.

Overview

🔐 A detailed example for how to encrypt data in an Elixir (Phoenix v1.7) App before inserting into a database using Ecto Types

Use Cases

Best For

  • Implementing GDPR-compliant data encryption in Phoenix applications
  • Learning how to build custom Ecto types for data transformation
  • Adding field-level encryption to existing Phoenix user schemas
  • Understanding AES-256-GCM encryption implementation in Elixir
  • Implementing secure password storage with Argon2 in Phoenix
  • Building applications that require encrypted personal data storage

Not Ideal For

  • Teams seeking a plug-and-play encryption library without manual Ecto type implementation
  • Projects built on non-Elixir stacks or using frameworks other than Phoenix
  • Developers under tight deadlines who need a production-ready, maintained encryption solution immediately
  • Applications requiring encryption algorithms or features beyond AES-256-GCM and Argon2, such as post-quantum cryptography

Pros & Cons

Pros

Comprehensive Educational Resource

Provides a step-by-step tutorial that explains encryption concepts from first principles, including detailed code for custom Ecto types and key rotation, making it ideal for deep learning.

OWASP Best Practices Compliance

Follows OWASP cryptographic storage and password storage cheat sheets by using AES-256-GCM encryption and Argon2 password hashing, ensuring industry-standard security.

Production-Ready Patterns

Includes practical implementations like key rotation with environment variable management and custom Ecto types for automatic encryption/decryption, derived from real-world use.

Hands-On Integration

Demonstrates full integration with Phoenix and Ecto, including schema changes, testing, and environment setup, covering the entire workflow from encryption to database storage.

Cons

Not a Maintained Library

The README explicitly recommends using the 'fields' library for production, indicating this example is primarily educational and may lack updates, bug fixes, or community support.

High Implementation Overhead

Requires copying and adapting code from the example, which involves manual setup of Ecto types, key management, and testing, increasing the risk of errors compared to using a pre-built solution.

Limited to Specific Tech Stack

Tied exclusively to Elixir, Phoenix, and Ecto, so it's not applicable for other programming languages, databases, or frameworks without significant rework.

Self-Managed Security Burden

Users must handle key generation, rotation, and algorithm updates themselves, which adds operational complexity and potential security gaps if not managed rigorously.

Frequently Asked Questions

Quick Stats

Stars291
Forks21
Contributors0
Open Issues8
Last commit1 month ago
CreatedSince 2018

Tags

#database#elixir#aes-256#phoenix#aes-encryption#ecto#phoenix-framework#database-encryption#encryption#password-hashing#field-level-encryption#aes-gcm#aes#learn#custom#cryptography#types#data-security#argon2#tutorial

Built With

E
Ecto
P
PostgreSQL
E
Elixir
P
Phoenix

Included in

Elixir13.1k
Auto-fetched 1 day ago

Related Projects

magnetissimomagnetissimo

Web application that indexes all popular torrent sites, and saves it to the local database.

Stars3,082
Forks185
Last commit2 years ago
changelog.comchangelog.com

Changelog makes world-class developer pods. This is our open source platform.

Stars2,766
Forks245
Last commit7 days ago
elixir_koanselixir_koans

Elixir learning exercises

Stars2,398
Forks617
Last commit7 months ago
hexpmhexpm

API server and website for Hex

Stars1,158
Forks308
Last commit1 day ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub