The Algorithm Design Manual
About the Book
Programming Challenges

The Stony Brook Algorithm Repository

Steven Skiena
Stony Brook University
Dept. of Computer Science

1.7.6 Cryptography

Problem Input | Problem Output

INPUT                    OUTPUT

Input Description: A plaintext message T or encrypted text E, and a key k.

Problem: Encode T using k giving E, or decode E using k back to T.

Excerpt from The Algorithm Design Manual: Cryptography has grown substantially in importance in recent years, as computer networks have made confidential documents more vulnerable to prying eyes. Cryptography is a way to increase security by making messages difficult to read if they fall into the wrong hands. Although the discipline of cryptography is at least two thousand years old, its algorithmic and mathematical foundations have recently solidified to the point where there can now be talk of provably secure cryptosystems.

The key issue in selecting a cryptosystem is identifying your paranoia level, i.e. deciding how much security you need. Who are you trying to stop from reading your stuff: your grandmother, local thieves, the Mafia, or the NSA? If you can use an accepted implementation of RSA, such as PGP discussed below, you should feel safe against just about anybody.


  • Nettle - a low-level cryptographic library (C) (rating 10)
  • Crypto++ (C++) (rating 9)
  • GnuPG: GNU Privacy Guard (C) (rating 8)
  • OpenSSL: The Open Source toolkit for SSL/TLS (C) (rating 8)
  • Boost: C++ Libraries (C++) (rating 7)
  • Netlib / TOMS -- Collected Algorithms of the ACM (FORTRAN) (rating 3)

  • Recommended Books

    Practical Algorithms for Programmers by A. Binstock and J. Rex Protect your Privacy: a guide for PGP Users by W. Stallings Applied Cryptography : Protocols, Algorithms, and Source Code in C by Bruce Schneier
    Differential Cryptanalysis of the Data Encryption Standard by E. Biham and A. Shamir Compared to What? by G. Rawlins Introduction to Algorithms by T. Cormen and C. Leiserson and R. Rivest and C. Stein
    Cryptography and Data Security by D. Denning The Code breakers: the story of secret writing by D. Kahn

    Related Links

  • A comprehensive overview of cryptographic algorithms by NIST

    Related Problems

    Factoring and Primality Testing
    Arbitrary Precision Arithmetic
    Text Compression

    This page last modified on 2008-07-10 .