Key principles of data password protection
1. Key is stored within the document. When someone attempts to open the document, the program checks whether the key entered is the same as the stored one. If the key doesn’t match, the program locks further processing of the document.
2. A key hash is stored within the document. "A hash function is a function, mathematical or otherwise, that takes a variable-length input string (called a pre-image) and converts it to a fixed-length (generally smaller) output string (called a hash value)." (Bruce Schneier). When this method is employed, a key entered by a user is being transformed into a data string of fixed length used to verify the key, but that string cannot be used to retrieve the key itself.
3. A key is used to encrypt the document with a certain algorithm. The protection reliability depends only on releability of the algorithm and the length of the key.
http://www.elcomsoft.com