Cryptography
From block cipher modes, key derivation and certificates to OpenPGP keys, the post-quantum migration and identity systems, cryptography as told through the free samples of the Leanpub books about it.
Created from the free samples of 10 Leanpub books and the descriptions and tables of contents of 15 more, with every source cited.
Cryptography is the practice of protecting information by transforming it with keys, so that only those holding the right key can read it, alter it undetected or claim to have written it. A cookbook in the library lists the four services it exists to provide: confidentiality, which restricts the content of data to those authorised to see it; integrity, which lets a receiver verify that data has not been changed; identification and authentication, which establish where a message came from; and non-repudiation, which prevents a sender from denying it.[1] They are achieved, the same book says, with four tools: symmetric ciphers, in which one secret key both encrypts and decrypts; secure hashes, one-way functions that reduce a message to a short value; asymmetric or public-key algorithms, which use a pair of keys; and digital signatures, which combine a hash with a private key.[1]
The subject has a settled core and an unsettled edge. The core, ciphers and their modes, key exchange, certificates, is taught on the shelf by recipe, in the commands of OpenSSL and the libraries of five programming languages. The edge is the replacement of today's public-key algorithms before a quantum computer can break them, a threat one author insists is logistical rather than theoretical, since traffic encrypted now can be stored and opened later.[2] Around both lies identity, the systems that decide who a key or a login belongs to, which the library's catalogue files under the same heading.
This article follows the subject from its building blocks outward: where to begin, the history, symmetric ciphers and hashes, public keys and certificates, cryptography in program code, OpenPGP and personal keys, the post-quantum migration, implementation and attack, identity and access, and the uses of cryptography in blockchains and in security examinations. Its sources are the free samples of the Leanpub books listed at the end, with the descriptions and tables of contents of the books whose samples were not available, and every claim that rests on a source is cited to it.
Where to start
The shelf has no gentle first book on the mathematics; its introductions are practical. The Modern Cryptography CookBook (2018) opens with a glossary and an account of what each kind of algorithm is for before it turns to commands,[1] and a newcomer to security generally can find the classical ciphers and hashing in one chapter of Cybersecurity from Beginner to Paid Professional, Part 1.[17] For the identity side, IAM A Complete Visual Guide (2026) is an illustrated introduction for new engineers, students and career changers.[5]
A programmer who needs working code should go to the cookbook for the language in hand: Python Cryptography for Python,[7] Cryptography for Java Script Developer for JavaScript in the browser,[8] GoLang Cryptography for Developer for Go,[9] Cryptography for PHP Developers for PHP,[10] and, at much greater length, Java Cryptography: Tools and Techniques for Java.[11] An engineer or maintainer who has to sign code and mail can start with The GPG Guide (2026), which marks its sections for three kinds of reader, from one who only needs to sign commits to one who maintains software packages.[3]
The advanced books assume the basics. Post-Quantum, Measured is for security engineers, people who run certificate infrastructure and developers;[2] Advanced Cryptography: Professional Implementation Handbook is for experienced developers, auditors and architects;[4] and Building Identity Systems That Don’t Break is for senior engineers responsible for single sign-on in production.[6]
History
Secret writing is ancient, and until the twentieth century it meant ciphers worked by hand or by machine and broken by analysis of the language underneath. Modern cryptography dates from the 1970s, when a public standard for symmetric encryption was published and when Diffie and Hellman, and then Rivest, Shamir and Adleman, showed that two parties could agree on a secret, or sign a message, without having shared a key in advance. The 1990s brought strong cryptography to ordinary users through PGP and the protocol that became TLS, and the present standard cipher, AES, was adopted in 2001.
The books add the dates that matter for their own subjects. The algorithm known as RSA takes its name from the three men who first described it publicly in 1978.[7] The two quantum algorithms that define the current threat were published in 1994 and 1996, and the three standards for algorithms meant to resist them were finalised by the American standards institute in August 2024.[2] In 2022 one of the candidates for that role, a key exchange built on maps between elliptic curves, was broken outright by a classical attack, which the handbook that recounts it takes as proof that mathematical elegance does not guarantee security.[4] And in 2023 the standard for OpenPGP was revised, the maintainer of its most widely used implementation declined to follow the revision, and the format has been split in two since.[3]
Symmetric ciphers, modes and hashes
A block cipher such as AES encrypts a fixed-size block, and the mode of operation determines how it is applied to a whole message. The Modern Cryptography CookBook goes through them in order. In the simplest, each block is encrypted separately; in cipher block chaining each block is first combined with the ciphertext of the one before, so that every block depends on all that preceded it, and a fresh initialisation vector makes each message unique; counter mode turns the cipher into a stream and lets blocks be processed in parallel; and one mode exists only for encrypting storage devices. None of these, the book stresses, provides integrity. For that there are the authenticated modes, which encrypt and detect tampering together, and of which Galois/Counter Mode is the most widely standardised. The chapter ends with the rule most often broken in practice: a mode that takes an initialisation vector needs a new one for every encryption, and for some modes it must be unpredictable.[1]
The same book sets out what symmetric algorithms cannot do. They give confidentiality, and with a message authentication code integrity and authentication, but not non-repudiation, since both parties hold the same key, and they leave open the question of how that key is to be distributed.[1] Passwords need a different tool again, a function that turns a password and a salt into a key slowly and with a deliberate use of memory: GoLang Cryptography for Developer devotes its sampled chapter to Argon2, with its parameters for time, memory and parallelism and the advice to use one variant, Argon2id, when in doubt.[9] NETWORK SECURITY MANAGEMENT (2020) introduces the same ground briefly in a book mostly about networks,[16] and Ethical Password Cracking approaches stored credentials from the other side, how they are recovered in an audit.[18]
Public keys, certificates and PKI
Public-key cryptography uses pairs of keys, one distributed widely and one known only to its owner, and so does two things: it lets anyone encrypt a message that only the holder of the private key can read, and it lets anyone verify that a message was produced by that holder.[7] Its commonest use is not encryption but agreement. In the Python cookbook's first recipe two parties derive a shared secret over an insecure channel with an elliptic-curve exchange, and the secret is then passed through a key derivation function before it is used as a key.[7] The other use is the signature: the sender hashes the message and applies a private key to the hash, and the receiver, hashing the message again, can tell both that it is unaltered and who sent it.[1]
A public key is only useful if one knows whose it is, and the answer in most systems is a certificate, a document that identifies the holder of a key and is signed by an authority.[1] The Modern Cryptography CookBook builds a chain of them with OpenSSL, a root authority, an intermediate and a client certificate, and explains the fields of the standard format;[1] its later chapters, by its contents, configure TLS on the common web servers. Java Cryptography: Tools and Techniques treats the same machinery for developers who must produce and manage certificates, signed and encrypted messages and time stamps in Java.[11] The mathematics underneath is the subject of Cryptography number theory and ai security (2026), a textbook that leads from number theory to cryptography and on to the use of AI in security.[13]
Cryptography in program code
Four short cookbooks by one author give working code, one language each, and all date from 2018 and 2019. Python Cryptography uses three Python libraries and includes the web's formats for keys, signatures and encrypted tokens.[7] Cryptography for Java Script Developer begins with a table of the JavaScript libraries then available, several of which it marks as no longer maintained, and settles on the interface built into browsers and one academic library.[8] GoLang Cryptography for Developer gives a complete Go program and its output for each primitive.[9] Cryptography for PHP Developers is organised by the names of PHP's OpenSSL functions, the first of which simply lists the ciphers the installation supports.[10] Their age shows, and they are best read as catalogues of what each library offers rather than as advice on what to choose.
Java Cryptography: Tools and Techniques (2025) is the substantial book of the kind. It starts from the provider architecture of the Java runtime and the place of the Bouncy Castle libraries in it, with a section on entropy and on what a number of bits of security means, and goes on to block and stream ciphers, certificates, the message formats built on them, OpenPGP, TLS and post-quantum algorithms.[11]
OpenPGP and personal keys
The GPG Guide is a reference for running a long-lived personal identity with OpenPGP, which it calls the most widely deployed public-key standard outside TLS: it underlies signed commits, encrypted mail, the verification of software packages and at least one password manager. Its first chapter describes a divided ecosystem. The 2023 revision of the standard introduced a new key format with mandatory authenticated encryption; GnuPG, the implementation on almost every system, follows a rival specification and refuses to import the new keys; so the guide's advice for 2026 is to generate keys in the older format, which every implementation accepts, and to ignore the new one until that changes. Its choice of algorithms is an elliptic-curve pair for signing and encryption, which it says gives the security of a much longer RSA key with keys and signatures a fraction of the size, and its key architecture is a master key kept offline that certifies separate subkeys for signing, encryption and authentication.[3] The guide also says where PGP is the wrong tool.[3] An adjacent book, a user's guide to the anonymous web, gives the same technology one chapter as a means of private correspondence.[20]
The post-quantum migration
Post-Quantum, Measured (2026) opens with a threat model rather than with physics. A sufficiently large quantum computer running Shor's algorithm would break RSA and the elliptic-curve algorithms in use for key exchange and signatures, and no larger key helps, since a key twice as long falls about as fast; one running Grover's algorithm would halve the effective key length of symmetric ciphers, which is survivable. What the first algorithm exploits, the book explains, is a periodic structure hidden in the problems on which public-key cryptography rests, which a quantum computer can find quickly and a classical one cannot. No such machine exists, and credible estimates put one at least a decade away. The argument for acting now is that a secret encrypted today may still need protecting when one does exist, and that the standards and a mainstream library implementing them are already available.[2]
The book's distinguishing feature is a discipline about evidence. Every technical claim carries one of three labels, verified by a measurement that can be rerun from a public repository, reported from a standard or paper, or proposed and not yet built, a rule the author adopted after finding two of his own drafts describing the same design with different constructions and a third describing as finished a rollout that had not been implemented.[2]
Advanced Cryptography: Professional Implementation Handbook (2026) supplies the engineering rule for the transition: new algorithms should be deployed in hybrid constructions, a classical exchange and a post-quantum one combined so that the result is at least as strong as the stronger of the two, because confidence in the new mathematics is recent and one candidate has already fallen.[4] The tools are moving at different speeds; the GPG guide notes that post-quantum keys are experimental in the newest version of GnuPG.[3] Cryptography Algorithms - Second Edition (2026) is a survey of the algorithms that includes this ground with zero-knowledge proofs and homomorphic encryption.[12]
Implementation and attack
An algorithm that is secure on paper can be broken by the way it is run. The implementation handbook's example is a key exchange whose secret determines how many steps a computation takes: a straightforward implementation leaks the key through its running time, and the remedy is code that performs a fixed number of operations whatever the secret is.[4] The GPG guide makes the same point about hardware, preferring an algorithm whose signing has no branches that depend on the secret because a side-channel attack on security tokens was published in 2024.[3]
Two adjacent books look at cryptography from the attacker's position. Malware Development for Ethical Hackers gives four of its sixteen chapters to the hashes, ciphers and encodings that malicious software uses to hide itself,[19] and Ethical Password Cracking explains the arithmetic of guessing passwords against the ways they are stored.[18]
Identity and access
Keys and credentials belong to someone, and the discipline that manages the belonging is identity and access management. IAM A Complete Visual Guide defines it in one sentence, ensuring that the right human or workload can perform the right action on the right resource, under the right conditions, with a reliable record of what happened, and divides the work into four responsibilities: administering identities, authenticating them, authorising what they may do, and governing the whole. Authentication, it insists, answers whether a requester is who it claims to be and not what it may do; its comparison is a badge that opens the front door of a building and not every room inside. Every request, on its account, raises five questions: who or what is asking, for what action, on which resource, under what conditions, and how the decision will be recorded.[5] Zero Trust A Complete Visual Guide, by the same author, follows a single request through authentication, policy decision and enforcement.[15]
Building Identity Systems That Don’t Break (2026) is about what happens when these systems are chained. Single sign-on, its preface observes, is a domain where a system can appear to work perfectly through testing and certification and begin to fail weeks after it goes live, with repeated logins, broken logouts and sessions that exist in one system and not another; the configuration was correct and the understanding was shallow. Its method is to read the exchange itself, the redirects, cookies, assertions and tokens that pass through the browser, on the premise that someone who can read the wire can understand any identity system.[6] Decentralized Identity Explained (2024) takes the longer view, from conventional identity management to identities that their holders control.[14]
Blockchains and examinations
Cryptography reaches many readers through its applications. Mastering Taproot (2026) is a guide to one part of Bitcoin that begins with private keys, public keys and the encoding of addresses and applies a modern signature scheme and hash trees throughout;[21] The Web3 Book explains hashing, keys, signatures and zero-knowledge proofs for readers with no technical background;[22] and Implementation Guide for a Full System is a guide to a security standard for cryptocurrency custodians whose stated focus is the management of keys.[23] For many security professionals the subject is first met as a section of an examination syllabus, and the shelf's best-selling title under this heading is such a reference, CISSP: The Last Mile,[24] with UNLOCK CISSP as a set of revision notes for the same exam.[25]
Questions about Cryptography
Which cryptography book should I start with?
The shelf has no gentle first book on the mathematics, and its introductions are practical. The Modern Cryptography CookBook (2018) opens with a glossary and an account of what each kind of algorithm is for before it turns to commands.[1] A programmer who needs working code should go to the cookbook for the language in hand, such as Python Cryptography (2018) for Python, GoLang Cryptography for Developer (2018) for Go or the much longer Java Cryptography: Tools and Techniques (2025) for Java.[7][9][11]
What is the difference between symmetric and asymmetric encryption?
A symmetric cipher uses one secret key that both encrypts and decrypts, while an asymmetric or public-key algorithm uses a pair of keys.[1] Symmetric algorithms give confidentiality but not non-repudiation, since both parties hold the same key, and they leave open the question of how that key is to be distributed.[1] With a pair, one key is distributed widely and one is known only to its owner, so that anyone can encrypt a message that only the holder of the private key can read.[7]
Does AES encryption protect data from tampering?
Not in every mode. The Modern Cryptography CookBook goes through the modes of operation and stresses that the basic ones, cipher block chaining and counter mode among them, do not provide integrity.[1] For that there are the authenticated modes, which encrypt and detect tampering together, and of which Galois/Counter Mode is the most widely standardised.[1]
What is Argon2 used for?
Passwords need a function that turns a password and a salt into a key slowly and with a deliberate use of memory, and Argon2 is such a function. GoLang Cryptography for Developer devotes a chapter to it, with its parameters for time, memory and parallelism and the advice to use one variant, Argon2id, when in doubt.[9]
Will quantum computers break today's encryption?
A sufficiently large quantum computer running Shor's algorithm would break RSA and the elliptic-curve algorithms in use for key exchange and signatures, while one running Grover's algorithm would halve the effective key length of symmetric ciphers, which is survivable.[2] No such machine exists, and Post-Quantum, Measured (2026) reports credible estimates that put one at least a decade away.[2] Its argument for acting now is that a secret encrypted today may still need protecting when one does exist.[2]
What is the difference between authentication and authorization?
Authentication answers whether a requester is who it claims to be, and not what it may do, which is the separate work of authorisation.[5] IAM A Complete Visual Guide (2026) compares authentication to a badge that opens the front door of a building and not every room inside.[5]
Sources
Every source is a Leanpub book. The note after each says which part of it was read; where no sample was available, only the public description and table of contents were used.
- 1.The Modern Cryptography CookBook, Anish Nath: Cryptography is for EveryOne. Learn from Crypto Principle to Applied Cryptography With Practical Example Free sample: the goals and glossary of cryptography, the chapter on symmetric ciphers, modes and initialisation vectors, and the start of the chapter on PKI. 2018. Free sample: PDF · EPUB
- 2.Post-Quantum, Measured, Danny B. Carr, Jr.: Migrating TLS, PKI, and application crypto with evidence you can reproduce Free sample: the front matter and preface on how claims are labelled, and the opening of chapter one on what quantum computers do to cryptography. 2026. Free sample: PDF · EPUB
- 3.The GPG Guide, Tony Gies: Modern OpenPGP for Every Workflow Free sample: the introduction and the chapters on the state of OpenPGP in 2026 and on cryptographic choices. 2026. Free sample: PDF · EPUB
- 4.Advanced Cryptography: Professional Implementation Handbook, Krzysztof Rybiński Free sample: the table of contents and two chapters, on isogeny-based cryptography and on hybrid protocols. 2026. Free sample: PDF
- 5.IAM A Complete Visual Guide, Reiner Braun: Complete Practical Guide: Foundations, Lifecycle, Authentication, Authorization, Cloud, Workloads, Operations, and Delivery Free sample: the introduction and chapter one, on the access question and the four responsibilities of identity and access management. 2026. Free sample: PDF · EPUB
- 6.Building Identity Systems That Don’t Break, Binit Datta: Spring Boot, Spring Security, Keycloak, Okta SAML 2.0, and Just-In-Time Provisioning Free sample: the front matter, the preface and the table of contents. 2026. Free sample: PDF
- 7.Python Cryptography, Anish Nath: Python Cryptography Free sample: the chapter on asymmetric-key algorithms. 2018. Free sample: PDF · EPUB
- 8.Cryptography for Java Script Developer, Anish Nath Free sample: the table of JavaScript libraries and recipes for generating keys and encrypting with AES. 2018. Free sample: PDF · EPUB
- 9.GoLang Cryptography for Developer, Anish Nath Free sample: three chapters, on Argon2, DSA and Curve25519. 2018. Free sample: PDF · EPUB
- 10.Cryptography for PHP Developers, Anish Nath Free sample: the functions that list available ciphers and digests. 2019. Free sample: PDF · EPUB
- 11.Java Cryptography: Tools and Techniques, David Hook, Jon Eaves No sample: from the description and table of contents. 2025.
- 12.Cryptography Algorithms - Second Edition, Packt Publishing Ltd: Explore New Algorithms in Zero-knowledge, Homomorphic Encryption, and Quantum Cryptography No sample: from the description alone; the table of contents is empty. 2026.
- 13.Cryptography number theory and ai security, Anshuman Mishra: Foundations and applications No sample: from the description and table of contents. 2026.
- 14.Decentralized Identity Explained, Packt Publishing Ltd: Embrace decentralization for a more secure and empowering digital experience No sample: from the description and table of contents. 2024.
- 15.Zero Trust A Complete Visual Guide, Reiner Braun: A Practical Visual Learning Guide From the description and table of contents. 2026. Free sample: PDF · EPUB
- 16.NETWORK SECURITY MANAGEMENT, Joseph Thachil George From the description and table of contents. 2020. Free sample: PDF
- 17.Cybersecurity from Beginner to Paid Professional, Part 1, Bolakale Aremu: Protecting Systems, Data and Networks From the description and table of contents; the sample does not reach the cryptography chapter. 2026. Free sample: PDF
- 18.Ethical Password Cracking, Packt Publishing Ltd: Decode passwords using John the Ripper, hashcat, and advanced methods for password breaking No sample: from the description and table of contents. 2024.
- 19.Malware Development for Ethical Hackers, Packt Publishing Ltd: Learn how to develop various types of malware to strengthen cybersecurity No sample: from the description and table of contents. 2025.
- 20.Encyclopedia Cyberspacia, Lefty Insider: The 42nd and Final Encyclopedia Cyberspacia From the description and table of contents. 2023. Free sample: PDF
- 21.Mastering Taproot, Aaron Zhang : Unlocking Bitcoin’s Future: Taproot Script Engineering for Developers No sample: from the description and table of contents. 2026.
- 22.The Web3 Book, Bruno Pierri Galvao: Making Sense of the Internet's Next Era From the description and table of contents. 2026. Free sample: PDF · EPUB
- 23.Implementation Guide for a Full System, Manan Vora: By Manan Vora & Marc Krisjanous No sample: from the description alone; the table of contents is empty. 2023.
- 24.CISSP: The Last Mile, Pete Zerger: Your guide to the finish line No sample: from the description and table of contents. 2025.
- 25.UNLOCK CISSP, Anoop A. Shetty: Essential Notes for Exam Day Success No sample: from the description and table of contents. 2025.
Further reading
Other books in the library on the same ground, not cited above.
- A Go Developer's Notebook, Eleanor McHugh: Where I Go During My Holidays A code-first exploration of Go whose first chapter includes a network program obscured with RSA. 2019. Free sample: PDF · EPUB
- Solidity Programming Essentials, Anish Nath A short guide to Solidity smart contracts, with one chapter on its cryptographic functions. 2021. Free sample: PDF · EPUB
- Beyond Blockchain: The Futurist Guide to Innovative Technologies, Andrew Magdy Kamal A survey of blockchain and other emerging technologies, with sections on hash trees, ring signatures and quantum cryptography. 2020.
- Guardians of Privacy, Solidity Academy: Unveiling the Nexus of Blockchain & Artificial Intelligence in Digital Identity and IoT Privacy and digital identity where connected devices meet artificial intelligence, treated as a matter of governance. 2024. Free sample: PDF
- Twenty One Million, Ritesh Modi: The Inner Workings of Blockchain and Bitcoin A novel in which four colleagues work out on a whiteboard how Bitcoin works, keys and signatures included. 2026. Free sample: PDF
- The Market for Truth: Engineering Honesty in the Age of the Zero-Cost Lie, Ali Sadhik Shaik An argument that online trust must be engineered, proposing a protocol that draws on cryptography, game theory and economics. 2026. Free sample: PDF · EPUB