We propose quantum cryptography based on an algorithm of determining a function using qudit systems. The security of our cryptography is based on the Ekert 1991 protocol, that is, we use an entangled state. An eavesdropper must destroy the entangled state. Consider one of many functions. Alice selects a secret function. Bob's aim is of determining the selected function (a key) without the eavesdropper knows it. To select the same function, in classical case, at the worst case, Bob needs many queries to Alice. In quantum case, Bob needs just a query. By measuring the single entangled state, which is sent by Alice, Bob can obtain the selected function. This is faster than classical cryptography.