Visual Cryptography is a cryptographic technique which allows visual image to be encrypted in such a way that the decrypted information is a visual image. One of the best-known schemes is by Adi Shamir & Moni Naor developed 1994. visual cryptography is easy to decode, implement and requires no cryptographic computations. It can be used for secret sharing, In which an image is broken into n shares and only someone with all the n shares is able to decrypt the image. The method can be extended to allow k out of n shares to be enough for the secret to be revealed. Here I implemented n out of n scheme for small values of n. To understand how everything works, I recommend reading the original paper. Alternatively you can read this blog post by Nick Berry. There are also comments and implementation notes in the source code.
You can run the code using binaries at /bin. Alternatively you can use run the source code in /src. use argument below followed by image addresses. Note that multi-mode takes three images as input whereas single-mode takes only one. Images must be encoded in png.
./main -help Usage of ./main: -multi-mode wether to use multi package to encrypt (default false) -n int number of transparencies, can't be used with multi-mode on (default 2)
./main -n 2 ../assets/example_2_2/dino.png
Example of 4-out-of-4 case. Top-left is a single transparency. Top-right is an image of two transparencies stacked. Bottom-left shows three stacked trasparencies. Only the last image reveals the secret.