A lock is a mechanical or electronic fastening device that is released by a physical object (such as a key, keycard, fingerprint, RFID card, or security token) or secret information (such as a keycode or password), or combination of more than one of these.
Typically, in pin-tumbler and wafer-tumbler applications, a lock in the rest position is closed. The key has a series of grooves on either side of the key (the key's blade), which limit the type of lock the key can slide into. As the key slides into the lock, the grooves on the blade of the key align with the wards in the keyway allowing or denying entry to the cylinder. Then, a series of pointed teeth and notches on the blade called bittings allow pins or wafers to move up and down until they are in line with the shear line of the inner and outer cylinder, allowing the cylinder or cam to rotate freely inside the lock and the lock to open.
Locks may be entirely mechanical, or electromechanical. They may be operated by turning some form of removable key, by keying or dialling in a combination which directly or via electromechanical means operates the lock, with some form of magnetic or other card reader, or by moving a part on a safety lock intended to prevent accidental operation rather than to prevent unauthorized access.