We propose a novel method for optical security by using a randomly selected binary phase code. The phase code is recorded with holographic volume gratings, and the recording material can be regarded as an optical lock, while the original phase code acts a