This question already has an answer here:
I am looking for a way to do multi-key encryption with the set number of decryption keys. The goal is to take a file, encrypt it and generate several decryption keys, in order to decrypt several (not just one, but all either) keys must be used.
Receive image.jpeg Generate an encrypted image.jpeg.crypt, image.jpeg.key1, image.jpeg.key2, image.jpeg.key3 Distribute keys to three different persons
After this 2 keys must be present to decrypt, but any 2 of the mentioned 3.
In perfect scenario i should be able to say: "Generate X keys, out of which Y keys will be required to decrypt".
P.S. This is not a duplicate of Encryption strategies for multi users access in production systems where any one key decrypts, nor is it a duplicate of Doubling up or cycling encryption algorithms where every key must be provided.