Free book sample

Password Hashing Fundamentals

Mastering One-Way Functions and Cryptographic Security

Secure password storage is the foundation of digital security, yet many systems still rely on outdated or inadequate hashing methods.

222 pages10 chaptersDec 7, 2025Cryptography Algorithms

Download sample:

About this book

This book equips you with the knowledge to implement cryptographically sound password hashing systems that protect user credentials against modern attacks. You'll explore the mathematical principles behind one-way functions, understand why traditional hashing algorithms have become obsolete, and learn how to select and implement modern algorithms like bcrypt, scrypt, and Argon2. Through practical examples and real-world scenarios, you'll discover how salt, computational cost, and memory requirements work together to create resilient password storage systems. Whether you're building authentication systems, auditing security infrastructure, or advancing your cryptographic expertise, this book provides the technical depth and practical guidance needed to make informed decisions about password security in your applications.

Table of contents

  1. IntroductionWhy Password Security Matters, What You'll Learn in This Book, Prerequisites and How to Use This GuideRead below
  2. Chapter 1: The Fundamentals of One-Way FunctionsDefining One-Way Functions, Mathematical Properties and Characteristics, One-Way Functions vs. Encryption, Computational Complexity and Feasibility
  3. Chapter 2: Hash Functions and Their Role in SecurityHash Function Basics and Properties, Collision Resistance and Avalanche Effect, General Hash Functions vs. Password Hashing, Cryptographic Requirements for Password Hashing
  4. Chapter 3: Legacy Algorithms and Why They FailedMD5: A Cautionary Tale, SHA Family Limitations for Password Storage, The Speed Problem: Why Fast Hashing Is Dangerous, Learning from Historical Breaches
  5. Chapter 4: Salt: The Essential Defense MechanismUnderstanding Salt and Its Purpose, Generating Cryptographically Secure Salt, Defeating Rainbow Tables and Dictionary Attacks, Storing and Managing Salt Properly
  6. Chapter 5: Bcrypt: The Industry StandardDesign Principles and History, How Bcrypt Works: The Blowfish Foundation, The Cost Factor and Adaptive Hashing, Implementing Bcrypt in Practice
  7. Chapter 6: Scrypt and Memory-Hard FunctionsThe Memory-Hard Concept, Scrypt Design and Parameters, Resistance to GPU and ASIC Attacks, Practical Considerations for Scrypt
  8. Chapter 7: Argon2: The Modern StandardEvolution and Password Hashing Competition, Argon2i, Argon2d, and Argon2id, Configuring Time, Memory, and Parallelism, Implementing Argon2 Securely
  9. Chapter 8: Attack Vectors and Defense StrategiesBrute-Force and Dictionary Attacks, Timing Attacks and Constant-Time Comparison, GPU and ASIC-Based Attacks, Comprehensive Defense Strategies
  10. Chapter 9: Implementing Secure Password SystemsDesigning Secure Authentication Architecture, Selecting the Right Algorithm for Your Needs, Code Examples and Best Practices, Testing and Validating Your Implementation
  11. Chapter 10: Future Trends and Emerging ThreatsQuantum Computing and Post-Quantum Cryptography, Emerging Algorithms and Research, Staying Current with Security Standards
  12. ConclusionKey Takeaways and Principles, Your Next Steps in Password Security
  13. Glossary
  14. Further Reading and Resources

Introduction

Every day, billions of authentication attempts occur across the internet. Users log into email accounts, banking systems, social media platforms, and countless other services. Behind each login lies a critical security decision: how should passwords be stored? This seemingly simple question has profound implications for the security of user data and the integrity of digital systems. A single misstep in password storage can expose millions of users to credential theft, identity fraud, and unauthorized access to sensitive information.

Password hashing represents one of the most fundamental security mechanisms in modern computing. Unlike encryption, which is designed to be reversible with the correct key, password hashing employs one-way functions that are computationally infeasible to reverse. This distinction is not merely academic—it forms the foundation of secure authentication systems. When implemented correctly, password hashing ensures that even if an attacker gains access to a database of hashed passwords, they cannot easily recover the original passwords. When implemented poorly, however, the consequences can be catastrophic, as demonstrated by numerous high-profile data breaches over the past two decades.

The landscape of password hashing has evolved dramatically since the early days of computing. What began with simple algorithms like MD5 and SHA-1 has progressed through bcrypt and scrypt to modern standards like Argon2. This evolution reflects an ongoing arms race between attackers and defenders. As computing power increases and new attack techniques emerge, password hashing algorithms must adapt to maintain their effectiveness. Understanding this evolution and the principles that drive it is essential for anyone responsible for implementing or maintaining authentication systems in today's threat environment.

This book bridges the gap between theoretical cryptography and practical implementation. You will explore the mathematical foundations of one-way functions, understand why certain algorithms have become obsolete, and learn how to implement modern password hashing systems that resist contemporary attacks. The knowledge presented here is not merely theoretical—it provides actionable guidance for building secure authentication systems that protect real users in production environments. Whether you are developing new applications, auditing existing systems, or advancing your expertise in cryptographic security, this book equips you with the understanding needed to make informed decisions about password security.

Why Password Security Matters

The consequences of inadequate password security extend far beyond technical failures. When password databases are compromised, the impact ripples through organizations and affects real people. Consider the 2012 LinkedIn breach, where approximately 6.5 million password hashes were stolen and subsequently cracked. The company had used unsalted SHA-1 hashes, a decision that made the passwords vulnerable to rapid cracking once the database was exposed[1]. Users who reused passwords across multiple services found their accounts compromised on entirely different platforms. This breach illustrates how password security failures create cascading vulnerabilities that extend beyond the initial point of compromise.

Financial institutions face particularly severe consequences from password security failures. Banking systems, payment processors, and financial services platforms store credentials that directly control access to monetary assets. A successful attack on these systems can result in direct financial losses, regulatory penalties, and irreparable damage to customer trust. The Payment Card Industry Data Security Standard (PCI DSS) explicitly requires strong cryptographic protection for stored credentials, recognizing that password security is not optional but essential for financial system integrity[2]. Organizations that fail to meet these standards face not only technical vulnerabilities but also legal and regulatory consequences.

Healthcare systems present another critical domain where password security directly impacts human welfare. Electronic health records contain sensitive medical information protected by regulations like HIPAA in the United States. Unauthorized access to these systems can expose patient diagnoses, treatment histories, and personal health information. Beyond privacy violations, compromised healthcare systems can disrupt medical services, delay treatments, and potentially endanger patient safety. The 2015 Anthem breach, which exposed personal information of nearly 80 million individuals, demonstrated how healthcare organizations become prime targets for attackers seeking valuable personal data[3].

The proliferation of password reuse amplifies the impact of any single security failure. Research consistently shows that users employ the same passwords across multiple services, despite security recommendations against this practice. When one service suffers a breach, attackers immediately attempt to use the stolen credentials on other platforms through credential stuffing attacks. This phenomenon transforms a breach at a low-security forum or gaming site into a potential compromise of email accounts, banking systems, and other critical services. Proper password hashing cannot prevent password reuse, but it can significantly slow attackers and provide time for users to change their credentials before they are exploited elsewhere.

Regulatory frameworks increasingly mandate specific password security practices. The European Union's General Data Protection Regulation (GDPR) requires organizations to implement appropriate technical measures to protect personal data, including authentication credentials. The California Consumer Privacy Act (CCPA) and similar state-level regulations in the United States impose requirements for data security and breach notification. Organizations that fail to implement adequate password security may face substantial fines, legal liability, and mandatory disclosure of security failures. These regulatory pressures reflect a broader recognition that password security is a fundamental component of data protection and privacy rights.

The economic costs of password-related breaches extend beyond immediate remediation expenses. Organizations face costs associated with forensic investigation, system remediation, customer notification, credit monitoring services, legal fees, and regulatory fines. The 2017 Equifax breach, which exposed personal information of 147 million people, ultimately cost the company over $1.4 billion in remediation and settlement expenses[4]. While the Equifax breach involved multiple security failures beyond password hashing, it illustrates the magnitude of financial consequences that can result from inadequate security practices. Investing in proper password security represents not merely a technical best practice but a sound business decision that protects organizational assets and reputation.

Attackers continue to develop increasingly sophisticated techniques for compromising password systems. Modern attackers employ GPU clusters, cloud computing resources, and specialized hardware to accelerate password cracking. Rainbow tables, dictionary attacks, and hybrid approaches combine to exploit weaknesses in password hashing implementations. The availability of leaked password databases from previous breaches provides attackers with extensive dictionaries of commonly used passwords and patterns. Understanding these attack vectors and implementing defenses against them is essential for maintaining effective password security in the face of evolving threats. The technical decisions you make about password hashing directly determine how well your systems resist these attacks.

The human element of password security cannot be ignored. Users create passwords that balance memorability with security requirements, often favoring convenience over cryptographic strength. While user education and password policies play important roles, the password hashing system must assume that some users will choose weak passwords. Strong password hashing algorithms provide defense in depth, ensuring that even weak passwords require substantial computational effort to crack. This protection buys time for detection, response, and user notification when breaches occur. Your choice of password hashing algorithm and its configuration parameters directly determines the level of protection provided to users who may not fully understand the security implications of their password choices.

What You'll Learn in This Book

This book provides comprehensive coverage of password hashing from mathematical foundations through practical implementation. You will begin by exploring one-way functions and their mathematical properties, understanding why these functions form the basis of secure password storage. The distinction between one-way functions and encryption is fundamental to password security, and you will develop a clear understanding of when each approach is appropriate. This foundation enables you to evaluate password hashing algorithms critically and understand the security properties they provide. You will learn to recognize the characteristics that make a function suitable for password hashing and identify weaknesses that compromise security.

The evolution of password hashing algorithms reveals important lessons about security design and the ongoing challenge of maintaining protection against advancing threats. You will examine legacy algorithms like MD5 and SHA-1, understanding not only how they work but why they have become inadequate for password storage. This historical perspective provides context for modern algorithms and helps you recognize similar weaknesses in future proposals. You will learn to identify the specific vulnerabilities that make fast hashing algorithms dangerous for password storage, including susceptibility to brute-force attacks, rainbow tables, and GPU-accelerated cracking. Understanding these failures informs better decisions about algorithm selection and implementation.

Salt represents a critical defense mechanism that transforms password hashing from vulnerable to robust. You will learn how salt defeats rainbow tables and prevents attackers from amortizing the cost of cracking across multiple passwords. The book covers proper salt generation using cryptographically secure random number generators, appropriate salt length, and correct storage practices. You will understand why salt must be unique per password and how to implement salt handling in your authentication systems. Practical examples demonstrate both correct and incorrect salt implementations, helping you avoid common pitfalls that undermine the security benefits salt provides.

Modern password hashing algorithms incorporate adaptive cost factors that allow security to scale with increasing computational power. You will explore bcrypt in depth, understanding its design principles, the Blowfish cipher foundation, and the cost factor that makes it resistant to brute-force attacks. The book provides guidance on selecting appropriate cost factors that balance security with user experience, considering factors like server capacity, expected authentication volume, and threat models. You will learn to implement bcrypt correctly in various programming environments and understand the trade-offs involved in different configuration choices. Real-world examples illustrate how organizations have successfully deployed bcrypt in production systems.

Memory-hard functions represent an important evolution in password hashing design, specifically targeting GPU and ASIC-based attacks. You will study scrypt's design and understand how memory requirements create economic barriers to large-scale password cracking. The book explains scrypt's parameters—CPU cost, memory cost, and parallelization—and how to configure them for different security requirements. You will learn when scrypt offers advantages over bcrypt and when other algorithms may be more appropriate. Practical considerations include memory availability on authentication servers, performance characteristics under load, and migration strategies for systems currently using other algorithms.

Argon2 represents the current state of the art in password hashing, having won the Password Hashing Competition in 2015. You will explore the three variants—Argon2i, Argon2d, and Argon2id—understanding the security properties and use cases for each. The book provides detailed guidance on configuring Argon2's time cost, memory cost, and parallelism parameters to achieve desired security levels. You will learn to implement Argon2 using established libraries and understand the security considerations involved in deployment. Comparative analysis helps you understand when Argon2 offers advantages over bcrypt or scrypt and how to make informed decisions about algorithm selection for new projects.

Understanding attack vectors is essential for implementing effective defenses. You will study brute-force attacks, dictionary attacks, rainbow tables, and hybrid approaches that combine multiple techniques. The book covers timing attacks and the importance of constant-time comparison functions for password verification. You will learn about GPU and ASIC-based attacks, understanding how specialized hardware accelerates password cracking and how memory-hard functions provide resistance. Defense strategies extend beyond algorithm selection to include rate limiting, account lockout policies, multi-factor authentication, and monitoring for suspicious authentication patterns. You will develop a comprehensive understanding of how these defenses work together to create robust authentication systems.

Implementation guidance bridges the gap between theoretical understanding and production systems. You will see code examples in multiple programming languages demonstrating correct password hashing implementation. The book covers common implementation errors, including improper salt handling, incorrect parameter selection, and insecure password comparison. You will learn to design authentication architectures that properly separate concerns, protect credentials in memory, and handle edge cases securely. Testing and validation procedures help ensure your implementation meets security requirements and performs adequately under expected load. Migration strategies address the challenge of upgrading existing systems from legacy algorithms to modern standards without disrupting service or compromising security.

The book concludes by examining future trends and emerging threats in password security. You will explore the potential impact of quantum computing on cryptographic systems and understand post-quantum cryptography research. Emerging algorithms and ongoing research in password hashing provide insight into how the field continues to evolve. You will learn strategies for staying current with security standards, monitoring for new vulnerabilities, and adapting your systems as threats evolve. This forward-looking perspective ensures that the knowledge you gain remains relevant as technology advances and new challenges emerge in the ongoing effort to protect user credentials.

Prerequisites and How to Use This Guide

This book assumes you have foundational knowledge of computer science and programming. You should be comfortable reading code examples in languages like Python, JavaScript, or similar high-level languages, though deep expertise in any particular language is not required. Basic understanding of algorithms and data structures helps you grasp the computational complexity discussions that appear throughout the book. Familiarity with binary representation, hexadecimal notation, and basic bitwise operations will aid your understanding of how hashing algorithms process data. If you have worked with databases and understand basic SQL operations, you will find the discussions of password storage and retrieval more immediately applicable to your work.

Some exposure to cryptographic concepts provides helpful context, though the book does not assume advanced cryptography knowledge. If you understand the difference between symmetric and asymmetric encryption, you have sufficient background to follow the discussions of one-way functions and their properties. The book explains cryptographic concepts as they become relevant, providing definitions and examples that build your understanding progressively. You do not need to be a mathematician to understand the material, but comfort with basic mathematical notation and logical reasoning will help you follow the explanations of algorithm properties and security proofs. The focus remains on practical understanding rather than rigorous mathematical formalism.

Experience with authentication systems, even at a basic level, helps you connect the concepts to real-world applications. If you have implemented user registration and login functionality, you will recognize the practical challenges that password hashing addresses. Understanding of web application architecture, including client-server communication and session management, provides context for where password hashing fits within larger authentication systems. However, the book explains these concepts sufficiently that you can follow the material even if your experience with authentication systems is limited. The goal is to build your understanding from foundational principles through practical implementation.

The book is structured to support multiple reading approaches depending on your goals and background. If you are new to password hashing, reading sequentially from beginning to end provides the most comprehensive understanding. Each chapter builds on concepts introduced in previous chapters, creating a coherent progression from fundamentals through advanced topics. If you have some experience with password hashing and want to deepen your knowledge of specific algorithms, you can focus on the chapters covering bcrypt, scrypt, and Argon2. These chapters are written to be largely self-contained while referencing earlier material where necessary. If you are primarily interested in implementation guidance, the later chapters on secure password systems and attack defense provide practical, actionable information.

Code examples throughout the book demonstrate concepts in multiple programming languages. These examples are intentionally simplified to highlight the relevant security concepts without obscuring them with production-level error handling and edge case management. When implementing password hashing in production systems, you should use established, well-tested libraries rather than implementing algorithms from scratch. The code examples serve to illustrate how the algorithms work and how to use libraries correctly, not as templates for custom implementations. Each example includes comments explaining the security-relevant aspects of the code and highlighting common mistakes to avoid.

Practical exercises appear at the end of most chapters, providing opportunities to apply the concepts you have learned. These exercises range from analytical questions that test your understanding of algorithm properties to implementation tasks that require you to write and test code. Working through these exercises reinforces your learning and helps you develop practical skills in password hashing implementation. Some exercises ask you to analyze existing code for security vulnerabilities, developing your ability to audit authentication systems. Others involve configuring algorithms with different parameters and measuring their performance characteristics, building intuition about the trade-offs involved in parameter selection.

The book includes references to academic papers, security standards, and technical documentation throughout. These references serve multiple purposes: they provide evidence for claims made in the text, point you to authoritative sources for deeper study, and help you develop the habit of consulting primary sources when making security decisions. You do not need to read all referenced materials to understand the book, but they are available if you want to explore particular topics in greater depth. The references also help you stay current with evolving standards and research by identifying the key publications and organizations that shape password hashing practices.

As you progress through the book, you will encounter discussions of trade-offs between security, performance, and usability. These trade-offs are inherent in password hashing system design, and there are rarely absolute right answers. The book provides frameworks for thinking about these trade-offs and making informed decisions based on your specific requirements and threat model. You will learn to ask the right questions: What are the consequences of a breach in your system? What computational resources are available for authentication? What user experience expectations must you meet? How quickly does your security posture need to adapt to emerging threats? Developing this decision-making framework is as important as understanding the technical details of specific algorithms.

The field of password security continues to evolve, and this book provides a foundation that remains relevant as new algorithms and attack techniques emerge. Rather than simply prescribing current best practices, the book develops your understanding of the principles that underlie secure password hashing. This principled understanding enables you to evaluate new algorithms, assess emerging threats, and adapt your implementations as the security landscape changes. The goal is not merely to teach you what to do today, but to equip you with the knowledge and analytical skills needed to make sound security decisions throughout your career. By understanding why certain approaches work and others fail, you develop the expertise needed to navigate future challenges in password security.

Back to contents

Notes

Introduction

  1. 1. Troy Hunt, "LinkedIn Lost 167 Million Account Credentials in Data Breach," Troy Hunt Blog, 2016
  2. 2. PCI Security Standards Council, "Payment Card Industry Data Security Standard v3.2.1," 2018
  3. 3. U.S. Department of Health and Human Services, "Breach Portal: Notice to the Secretary of HHS Breach of Unsecured Protected Health Information," 2015
  4. 4. Equifax Inc, "Annual Report 2019, Form 10-K," 2019

This is the end of the free sample. The full book has 10 chapters.

Want this book written for you?

Tell us your goals and background, and get your own version of this book, tailored by AI to you.

User avatar
User avatar
User avatar
User avatar
User avatar
9,183 books created by readers like you
As seen on:
Product HuntRedditMediumDEV

Benefits of AI-tailored books

Read one book, not ten:
all the Cryptography Algorithms knowledge you need, gathered into a single book.
Save days of learning:
tell us your goals, choose your topics, and the whole book is built around them.
Learn effortlessly:
Cryptography Algorithms book written for your specific background and expertise.
Understand at a glance:
includes charts, tables, timelines, checklists, decision trees, and more.
Stay current:
written the day you order it, not years ago.
Trust what you read:
every book is checked for accuracy, with real research when your subject needs it.

Create your unique book in 3 steps

1. Select your focus

Select the focus of your Cryptography Algorithms book and share your background

Your Cryptography Algorithms book focus
2. Personalize your book

Specify your goals and choose sub-topics to include

3. Get your tailored book

Your book is ready in 10 minutes. Read it online, download as EPUB or PDF, or send to Kindle.

Frequently asked questions

What is TailoredRead?

TailoredRead creates complete, full-length nonfiction ebooks, written specifically for you. Tell us what you want to learn and why, and TailoredRead writes you a complete ebook on it, with charts, tables, and diagrams throughout. Read it online, on Kindle, or on any e-reader, or download it as a PDF or EPUB. Every book is written fresh the day you order it.

How is the book tailored to me?

Before anything is written, you answer a few short questions about your goals, your background, and the topics you care about. Your book is then planned around your answers: written at your level, focused on your goals, and covering the topics you chose, instead of the one-size-fits-all book a store sells everyone.

Will it read like generic AI content?

No. Your book isn't a chat transcript: it's planned chapter by chapter before a single word is written, told in a clear book voice, and explains ideas visually with charts, tables, and diagrams. After writing, every book goes through an editorial pass that polishes chapters so the book reads consistent from start to finish. Judge for yourself: browse thousands of sample books on our Explore Books page.

How accurate is the content?

Our AI first checks whether your subject needs live research. Niche and fast-moving subjects are researched before writing, and the book plan and chapters are grounded in what it finds. After writing, every book goes through a quality pass that checks its facts and consistency, and researched books list their sources in a Notes section at the back.

How long is the book?

You choose the length: Comprehensive (250-300 pages), Detailed (150-200 pages), Essential (70-100 pages), or Short (30-50 pages).

Does the book include visuals?

Yes. Every book includes charts, tables, and diagrams: timelines, checklists, step-by-step guides, decision trees, comparison tables, matrices, and bar charts. A typical book includes dozens of these visual elements.

Can I read it on Kindle? What formats can I download?

Yes. Every book can be read in our online reader or downloaded as a PDF or EPUB. The EPUB can be opened with Kindle, Apple Books, Kobo, and any e-reader. The Commercial and Author licenses also include an editable Word (DOCX) and Markdown download.

How much does it cost?

About the price of a regular ebook. The exact price depends on your book's length and complexity, from $2 for the shortest books to $35 for the most comprehensive, and it's shown when you review your book, before you commit to anything. Each book is a one-time purchase, yours to keep, no subscription. Licenses that let you share, teach, or publish your book range from $35.99 to $49.99.

Can I preview the book before purchasing?

Before you pay, you'll see what your book will cover: the title, a detailed description, the estimated length, and the complete chapter-by-chapter table of contents, so you know what you're getting before you decide. The full text itself is written after you purchase.

How long does it take to create a book?

About 10 minutes. You can start reading the opening chapters while the rest is still being written.

Personalize and buy this book

Get your personalized version, tailored by AI to your goals, background, and interests