Knapsack is the problem of determining which numbers from a given collection of numbers have been added together to yield a specific sum: used in cryptography to encipher (and sometimes decipher) messages.

The knapsack problem is a NP-hard problem, which has led to attempts to use it as the basis for public-key encryption systems. Several such attempts failed because the knapsack problem instances they produced were in fact solvable by polynomial-time algorithms.