A removable and replaceable keying component which is required for operation of a mechanism and which component includes a waveguide having a photochromic portion. A method of controlling operation of a mechanism, preferably a dispenser, having a removable component comprising the steps of measuring electromagnetic radiation passing through a waveguide carrying at least in part on the removable component and permitting operation of the mechanism only when the measured electromagnetic radiation corresponds with one or more pre-selected parameters. Preferably, the method involves directing emitted electromagnetic radiation with pre-selected input parameters selected from a plurality of input parameters.